summaryrefslogtreecommitdiffstats
path: root/Core/User
diff options
context:
space:
mode:
Diffstat (limited to 'Core/User')
-rw-r--r--Core/User/ChainUserProvider.php15
-rw-r--r--Core/User/EntityUserProvider.php85
-rw-r--r--Core/User/InMemoryUserProvider.php2
-rw-r--r--Core/User/UserProviderInterface.php6
4 files changed, 16 insertions, 92 deletions
diff --git a/Core/User/ChainUserProvider.php b/Core/User/ChainUserProvider.php
index 6417f99..e6aca32 100644
--- a/Core/User/ChainUserProvider.php
+++ b/Core/User/ChainUserProvider.php
@@ -1,5 +1,14 @@
<?php
+/*
+ * This file is part of the Symfony framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
namespace Symfony\Component\Security\Core\User;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
@@ -41,11 +50,11 @@ class ChainUserProvider implements UserProviderInterface
/**
* {@inheritDoc}
*/
- public function loadUser(UserInterface $user)
+ public function refreshUser(UserInterface $user)
{
foreach ($this->providers as $provider) {
try {
- return $provider->loadUser($user);
+ return $provider->refreshUser($user);
} catch (UnsupportedUserException $unsupported) {
// try next one
}
@@ -67,4 +76,4 @@ class ChainUserProvider implements UserProviderInterface
return false;
}
-} \ No newline at end of file
+}
diff --git a/Core/User/EntityUserProvider.php b/Core/User/EntityUserProvider.php
deleted file mode 100644
index 61dd708..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 loadUser(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;
- }
-}
diff --git a/Core/User/InMemoryUserProvider.php b/Core/User/InMemoryUserProvider.php
index e73eb95..eae2083 100644
--- a/Core/User/InMemoryUserProvider.php
+++ b/Core/User/InMemoryUserProvider.php
@@ -78,7 +78,7 @@ class InMemoryUserProvider implements UserProviderInterface
/**
* {@inheritDoc}
*/
- public function loadUser(UserInterface $user)
+ public function refreshUser(UserInterface $user)
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
diff --git a/Core/User/UserProviderInterface.php b/Core/User/UserProviderInterface.php
index 79be191..11fd62c 100644
--- a/Core/User/UserProviderInterface.php
+++ b/Core/User/UserProviderInterface.php
@@ -33,7 +33,7 @@ interface UserProviderInterface
function loadUserByUsername($username);
/**
- * Loads the user for the account interface.
+ * Refreshes the user for the account interface.
*
* It is up to the implementation if it decides to reload the user data
* from the database, or if it simply merges the passed User into the
@@ -44,7 +44,7 @@ interface UserProviderInterface
*
* @return UserInterface
*/
- function loadUser(UserInterface $user);
+ function refreshUser(UserInterface $user);
/**
* Whether this provider supports the given user class
@@ -54,4 +54,4 @@ interface UserProviderInterface
* @return Boolean
*/
function supportsClass($class);
-} \ No newline at end of file
+}