예제 #1
0
 /**
  * Extract user groups for a given user.
  * @param \SLUB\Vk2\Domain\Model\User $user
  * @return array
  */
 public static function getUsergroupsForUser($user)
 {
     if (!$user) {
         return array();
     }
     $userGroup = $user->getUsergroup();
     $groups = array();
     foreach ($userGroup as $key => $value) {
         array_push($groups, $value->getTitle());
     }
     return $groups;
 }
예제 #2
0
 /**
  * @test
  */
 public function setNameForStringSetsName()
 {
     $this->subject->setName('Conceived at T3CON10');
     $this->assertAttributeEquals('Conceived at T3CON10', 'name', $this->subject);
 }
예제 #3
0
 /**
  * sign up a user
  * 
  * @param \SLUB\Vk2\Domain\Model\User $user
  */
 public function signupAction(\SLUB\Vk2\Domain\Model\User $user)
 {
     // check if user exist
     $userExist = Tools::getUserByUsername($this->userRepository, $user->getUsername());
     if (!empty($userExist[0])) {
         // redirect
         $errorMessage = array('msg' => 'Username is already in use.');
         $this->redirect('loginError', 'Auth', NULL, $errorMessage);
     }
     // attached usergroup to user
     $usergroup = $this->userGroupRepository->findByTitle('vk2-user')[0];
     $user->addUsergroup($usergroup);
     // hash passpord
     $user->hashPassword($this->vk2config['settings']['passwordSave']);
     // add user to database
     $this->userRepository->add($user);
     $this->persistenceManager->persistAll();
     $this->afterSignupDo($user);
 }