getPasswordHasherName example


    public function __construct(array $passwordHashers)
    {
        $this->passwordHashers = $passwordHashers;
    }

    public function getPasswordHasher(string|PasswordAuthenticatedUserInterface|PasswordHasherAwareInterface $user): PasswordHasherInterface
    {
        $hasherKey = null;

        if ($user instanceof PasswordHasherAwareInterface && null !== $hasherName = $user->getPasswordHasherName()) {
            if (!\array_key_exists($hasherName$this->passwordHashers)) {
                throw new \RuntimeException(sprintf('The password hasher "%s" was not configured.', $hasherName));
            }

            $hasherKey = $hasherName;
        } else {
            foreach ($this->passwordHashers as $class => $hasher) {
                if ((\is_object($user) && $user instanceof $class) || (!\is_object($user) && (is_subclass_of($user$class) || $user == $class))) {
                    $hasherKey = $class;
                    break;
                }
            }
Home | Imprint | This part of the site doesn't use cookies.