diff options
author | marc.weistroff <marc.weistroff@sensio.com> | 2011-07-13 08:41:17 +0200 |
---|---|---|
committer | marc.weistroff <marc.weistroff@sensio.com> | 2011-07-13 08:41:17 +0200 |
commit | e92d9dbcde69ce8b78dc3a5924390b15c80a1e2b (patch) | |
tree | 35714da8ab0665ad9897c140b106354bdf99130c | |
parent | ad6ee1fb40c193ddb4e79432c03b771591760122 (diff) | |
download | symfony-security-e92d9dbcde69ce8b78dc3a5924390b15c80a1e2b.zip symfony-security-e92d9dbcde69ce8b78dc3a5924390b15c80a1e2b.tar.gz symfony-security-e92d9dbcde69ce8b78dc3a5924390b15c80a1e2b.tar.bz2 |
[Security] Moved EntityUserProvider to Doctrine Bridge
-rw-r--r-- | Core/User/EntityUserProvider.php | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/Core/User/EntityUserProvider.php b/Core/User/EntityUserProvider.php deleted file mode 100644 index cc6f6ed..0000000 --- a/Core/User/EntityUserProvider.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\User; - -use Doctrine\ORM\EntityManager; -use Symfony\Component\Security\Core\Exception\UnsupportedUserException; -use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; - -/** - * Wrapper around a Doctrine EntityManager. - * - * Provides easy to use provisioning for Doctrine entity users. - * - * @author Fabien Potencier <fabien@symfony.com> - * @author Johannes M. Schmitt <schmittjoh@gmail.com> - */ -class EntityUserProvider implements UserProviderInterface -{ - private $class; - private $repository; - private $property; - - public function __construct(EntityManager $em, $class, $property = null) - { - $this->class = $class; - - if (false !== strpos($this->class, ':')) { - $this->class = $em->getClassMetadata($class)->name; - } - - $this->repository = $em->getRepository($class); - $this->property = $property; - } - - /** - * {@inheritdoc} - */ - public function loadUserByUsername($username) - { - if (null !== $this->property) { - $user = $this->repository->findOneBy(array($this->property => $username)); - } else { - if (!$this->repository instanceof UserProviderInterface) { - throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement UserProviderInterface.', get_class($this->repository))); - } - - $user = $this->repository->loadUserByUsername($username); - } - - if (null === $user) { - throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username)); - } - - return $user; - } - - /** - * {@inheritDoc} - */ - public function refreshUser(UserInterface $user) - { - if (!$user instanceof $this->class) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); - } - - return $this->loadUserByUsername($user->getUsername()); - } - - /** - * {@inheritDoc} - */ - public function supportsClass($class) - { - return $class === $this->class; - } -} |