/** * Tell if the the given user is this user * Useful when not hydrating all fields. * * @param User $user * @return boolean */ public function isUser(UserInterface $user = null) { return null !== $user && $this->getUsername() === $user->getUsername(); }
/** * {@inheritDoc} */ public function updatePassword(UserInterface $user) { if (0 !== strlen($password = $user->getPlainPassword())) { $user->setAlgorithm($this->algorithm); $encoder = $this->encoderFactory->getEncoder($user); $user->setPassword($encoder->encodePassword($password, $user->getSalt())); $user->eraseCredentials(); } }
/** * Indicates whether the given user and all compared objects correspond to the same record * * @param UserInterface $user * @param array $comparisons * @return boolean */ protected function anyIsUser($user, array $comparisons) { foreach ($comparisons as $comparison) { if (!$user->isUser($comparison)) { return false; } } return true; }