Sulu\Component\Security\Authentication\UserRepositoryInterface::findUserById PHP Method

findUserById() public method

Returns the user with the given id.
public findUserById ( integer $id ) : Sulu\Component\Security\Authentication\UserInterface
$id integer The user to find
return Sulu\Component\Security\Authentication\UserInterface
    public function findUserById($id);

Usage Example

Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function save($data, $userId, $id = null)
 {
     $name = $data['name'];
     try {
         // load existing tag if id is given and create a new one otherwise
         if ($id) {
             $tag = $this->tagRepository->findTagById($id);
             if (!$tag) {
                 throw new TagNotFoundException($id);
             }
         } else {
             $tag = new Tag();
         }
         $user = $this->userRepository->findUserById($userId);
         // update data
         $tag->setName($name);
         $tag->setChanger($user);
         if (!$id) {
             $tag->setCreator($user);
             $this->em->persist($tag);
         }
         $this->em->flush();
         return $tag;
     } catch (UniqueConstraintViolationException $exc) {
         throw new TagAlreadyExistsException($name);
     }
 }
All Usage Examples Of Sulu\Component\Security\Authentication\UserRepositoryInterface::findUserById