Exemple #1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     foreach ($this->groups as $name => $users) {
         $group = new Group();
         $group->setName($name);
         foreach ($users as $username) {
             $user = $this->getReference('user/' . $username);
             $group->addUser($user);
         }
         $manager->persist($group);
         $this->addReference('group/' . $name, $group);
     }
     $manager->flush();
 }
 protected static function createGroup($name, array $users = array(), array $roles = array())
 {
     $group = new Group();
     $group->setName($name);
     foreach ($users as $user) {
         $group->addUser($user);
     }
     foreach ($roles as $role) {
         $group->addRole($role);
     }
     self::create($name, $group);
 }