Exemple #1
0
 /**
  * @param Entity\User $user
  * @return void
  * @throws \LogicException If needed role can not be found
  */
 public function updateUserToKeyRole(Entity\User $user)
 {
     /** @var \Secretary\Entity\Role $roleRecord */
     $roleRecord = $this->getRoleRepository()->findOneBy(array('roleId' => 'keyuser'));
     if (empty($roleRecord)) {
         throw new \LogicException('Roles are missing, please configure them');
     }
     $user->getRoles()->clear();
     $user->addRole($roleRecord);
     $this->em->persist($user);
     $this->em->flush();
     return;
 }
 /**
  * {@inheritDoc}
  */
 public function getRoles()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getRoles', array());
     return parent::getRoles();
 }