Exemplo n.º 1
0
 /**
  * @param array $emails
  * @return User[]
  */
 public function getUsersByEmails(array $emails)
 {
     if (count($emails) === 0) {
         return [];
     }
     return $this->userRepository->findByEmails($emails);
 }
Exemplo n.º 2
0
 /**
  * @param $username
  *
  * @return UserInterface
  * @throws UsernameNotFoundException
  */
 public function loadUserByUsername($username)
 {
     $user = $this->userRepository->findOneBy(['username' => $username]);
     if (!$user) {
         throw new UsernameNotFoundException(sprintf('User with username: %s not found', $username));
     }
     return $user;
 }
Exemplo n.º 3
0
 public function getLoggedUser()
 {
     if (!$this->isUserLogged()) {
         return false;
     }
     if (!$this->loggedUser) {
         $userId = $this->container->get('request')->getSession()->get('user_id');
         $this->loggedUser = $this->userRepository->find($userId);
     }
     return $this->loggedUser;
 }
Exemplo n.º 4
0
 public function getTop()
 {
     /**
      * @TODO: FIX IT
      * I don't know WHY but I couldn't add the upvoteTotal in the UserEntity...
      * THUS, I have done a workaround thought out RAW SQL
      */
     $result = $this->repository->getTop();
     $data = array();
     foreach ($result as $row) {
         $user = new User();
         $user->setId($row['id']);
         $user->setFirstname($row['firstname']);
         $user->setLastname($row['lastname']);
         $user->setUsername($row['username']);
         $user->setPicturePath($row['picture_path']);
         $user->setUpvoteTotal($row['upvote_total']);
         $data[] = $user;
     }
     return $data;
 }
 public function testCountInactiveUsers()
 {
     $this->assertEquals(1, $this->repository->countInactiveUsers());
 }
 /**
  * Return a UserInterface object based on the credentials.
  *
  * The *credentials* are the return value from getCredentials()
  *
  * You may throw an AuthenticationException if you wish. If you return
  * null, then a UsernameNotFoundException is thrown for you.
  *
  * @param mixed $credentials
  * @param UserProviderInterface $userProvider
  *
  * @throws AuthenticationException
  *
  * @return UserInterface|null
  */
 public function getUser($credentials, UserProviderInterface $userProvider)
 {
     return $this->userRepository->findOneByApiToken($credentials);
 }
Exemplo n.º 7
0
 /**
  * Whether this provider supports the given user class.
  *
  * @param string $class
  *
  * @return bool
  */
 public function supportsClass($class)
 {
     $isClass = $this->userRepository->getClassName() === $class;
     $isSubClass = is_subclass_of($class, $this->userRepository->getClassName());
     return $isClass || $isSubClass;
 }
Exemplo n.º 8
0
 /**
  * @param string $username
  * @return User|null
  */
 public function loadUserByUsername($username)
 {
     return $this->userRepository->findByUsername($username);
 }
Exemplo n.º 9
0
 /**
  * Save User entity filled with LDAP data
  *
  * @param User $user
  */
 public function saveLDAPUserData(User $user)
 {
     $this->userRepository->saveUser($user);
 }
Exemplo n.º 10
0
 /**
  * @param $username
  *
  * @return User
  */
 public function getByUsername($username)
 {
     return $this->userRepository->getByUsername($username);
 }