Esempio n. 1
0
 public function load($manager)
 {
     $group = new \Club\UserBundle\Entity\Group();
     $group->setGroupName('Super Administrators');
     $group->setGroupType('static');
     $group->addRole($this->getReference('ROLE_SUPER_ADMIN'));
     $manager->persist($group);
     $group = new \Club\UserBundle\Entity\Group();
     $group->setGroupName('Event Managers');
     $group->setGroupType('static');
     $group->addRole($this->getReference('ROLE_EVENT_ADMIN'));
     $manager->persist($group);
     $manager->flush();
 }
Esempio n. 2
0
 private function initGroup()
 {
     $groups = array(array('name' => 'Super Administrators', 'type' => 'static', 'roles' => array('ROLE_SUPER_ADMIN')), array('name' => 'Event Managers', 'type' => 'static', 'roles' => array('ROLE_EVENT_ADMIN')), array('name' => 'Staff', 'type' => 'static', 'roles' => array('ROLE_STAFF')));
     foreach ($groups as $group) {
         $r = $this->em->getRepository('ClubUserBundle:Group')->getOneGroupByRoles($group['roles']);
         if (!$r) {
             $g = new \Club\UserBundle\Entity\Group();
             $g->setGroupName($group['name']);
             $g->setGroupType($group['type']);
             foreach ($group['roles'] as $role) {
                 $rol = $this->em->getRepository('ClubUserBundle:Role')->findOneBy(array('role_name' => $role));
                 $g->addRole($rol);
             }
             $this->em->persist($g);
         }
     }
 }