예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     //        $role_manager = $this->container->get('spomkylabs_role_hierarchy.role_manager');
     //        foreach ($this->getRoles() as $role) {
     //            $entity = $role_manager->createRole();
     //            $parent = null === $role['parent'] ? null : $this->getReference('role-' . $role['parent']);
     //            $entity->setName($role['name'])
     //                    ->setParent($parent);
     //            $role_manager->saveRole($entity);
     //            $this->addReference('role-' . $role['name'], $entity);
     //        }
     //
     foreach ($this->getRoles() as $role) {
         $newRoles = new Role();
         $parent = $role['parent'];
         $newRoles->setName($role['name']);
         $newRoles->setParent($parent);
         $manager->persist($newRoles);
         $manager->flush();
     }
 }
예제 #2
0
파일: User.php 프로젝트: hpdev225/myguard
 public function addRole($role)
 {
     !$role instanceof Role && ($role = new Role($role));
     $role->addUser($this, false);
     $this->roles->add($role);
     return $this;
 }