Example #1
0
 /**
  * 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();
 }
Example #2
0
 /**
  * {@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();
     }
 }
Example #3
0
    /**
     * 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;
    }