diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2012-06-18 08:12:50 +0200 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2012-06-18 08:12:50 +0200 |
commit | e13a63c0cbbd938589e2ecdf6af0402651cbb673 (patch) | |
tree | 84af98c95faf22555a8591efeb28f42fe5eb53f4 /Core/Encoder/EncoderFactory.php | |
parent | 81db3fb8af37dd884580433a647df23d6de5347e (diff) | |
download | symfony-security-e13a63c0cbbd938589e2ecdf6af0402651cbb673.zip symfony-security-e13a63c0cbbd938589e2ecdf6af0402651cbb673.tar.gz symfony-security-e13a63c0cbbd938589e2ecdf6af0402651cbb673.tar.bz2 |
[Security] allowed class names to be passed as an argument to EncoderFactoryInterface::getEncoder()
Diffstat (limited to 'Core/Encoder/EncoderFactory.php')
-rw-r--r-- | Core/Encoder/EncoderFactory.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Core/Encoder/EncoderFactory.php b/Core/Encoder/EncoderFactory.php index 738706a..866c809 100644 --- a/Core/Encoder/EncoderFactory.php +++ b/Core/Encoder/EncoderFactory.php @@ -30,10 +30,10 @@ class EncoderFactory implements EncoderFactoryInterface /** * {@inheritDoc} */ - public function getEncoder(UserInterface $user) + public function getEncoder($user) { foreach ($this->encoders as $class => $encoder) { - if (!$user instanceof $class) { + if ((is_object($user) && !$user instanceof $class) || (!is_subclass_of($user, $class) && $user != $class)) { continue; } @@ -44,7 +44,7 @@ class EncoderFactory implements EncoderFactoryInterface return $this->encoders[$class]; } - throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', get_class($user))); + throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', is_object($class) ? get_class($user) : $class)); } /** |