Exemplo n.º 1
0
 /**
  * create the default data for the groups module
  *
  * @return void
  */
 public function defaultdata()
 {
     $records = [['name' => $this->__('Users'), 'description' => $this->__('By default, all users are made members of this group.'), 'prefix' => $this->__('usr'), 'users' => [1, 2]], ['name' => $this->__('Administrators'), 'description' => $this->__('Group of administrators of this site.'), 'prefix' => $this->__('adm'), 'users' => [2]]];
     foreach ($records as $record) {
         $group = new GroupEntity();
         $group->setName($record['name']);
         $group->setDescription($record['description']);
         $group->setPrefix($record['prefix']);
         foreach ($record['users'] as $uid) {
             $user = $this->entityManager->find('ZikulaUsersModule:UserEntity', $uid);
             $user->addGroup($group);
         }
         $this->entityManager->persist($group);
     }
     $this->entityManager->flush();
 }
Exemplo n.º 2
0
 public function removeGroup(GroupEntity $group)
 {
     $group->removeUser($this);
     $this->groups->removeElement($group);
 }