Skip to content

Instantly share code, notes, and snippets.

@makasim
Created July 12, 2011 08:53
Show Gist options
  • Save makasim/1077647 to your computer and use it in GitHub Desktop.
Save makasim/1077647 to your computer and use it in GitHub Desktop.
<?php
/**
* @see Symfony\Component\Security\Core\Encoder\EncoderFactory::getEncoder()
*/
public function getEncoder(SecurityUserInterface $user)
{
if (!$user instanceof UserInterface) {
return $this->genericFactory->getEncoder($user);
}
if (isset($this->encoders[$algorithm = $user->getAlgorithm()])) {
return $this->encoders[$algorithm];
}
return $this->encoders[$algorithm] = $this->createEncoder($algorithm);
}
/**
* @see Symfony\Component\Security\Core\Encoder\EncoderFactory::getEncoder()
*/
public function getEncoder(SecurityUserInterface $user)
{
try {
return $this->genericFactory->getEncoder($user);
} catch (\RuntimeException $e) {
if (isset($this->encoders[$algorithm = $user->getAlgorithm()])) {
return $this->encoders[$algorithm];
}
return $this->encoders[$algorithm] = $this->createEncoder($algorithm);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment