Пример #1
0
 /**
  * @inheritdoc
  */
 public function load(ObjectManager $manager)
 {
     $adminPerm = $manager->merge($this->getReference('permission-ROLE_ADMIN'));
     $projectCreatePerm = $manager->merge($this->getReference('permission-ROLE_PROJECT_CREATE'));
     $projectReadPerm = $manager->merge($this->getReference('permission-PROJECT_READ'));
     $projectAdminPerm = $manager->merge($this->getReference('permission-PROJECT_ADMIN'));
     $admin = new Role('Administrator', 'admin', 'Master of the application', true);
     $admin->addPermission($adminPerm);
     $admin->addPermission($projectCreatePerm);
     $manager->persist($admin);
     $this->setReference('role-admin', $admin);
     $projectCreator = new Role('Project creator', 'project-creator', 'Capable to create projects', true);
     $projectCreator->addPermission($projectCreatePerm);
     $manager->persist($projectCreator);
     $this->setReference('role-project-creator', $projectCreator);
     $leadDev = new Role('Lead developer', 'lead-dev', 'Merge leader', false);
     $leadDev->addPermission($projectReadPerm);
     $leadDev->addPermission($projectAdminPerm);
     $manager->persist($leadDev);
     $this->setReference('role-lead-developer', $leadDev);
     $developer = new Role('Developer', 'dev', 'No admin access to repositories', false);
     $developer->addPermission($projectCreatePerm);
     $developer->addPermission($projectReadPerm);
     $manager->persist($developer);
     $this->setReference('role-developer', $developer);
     $visitor = new Role('Visitor', 'visitor', 'Read-only viewers', false);
     $visitor->addPermission($projectReadPerm);
     $manager->persist($visitor);
     $this->setReference('role-visitor', $visitor);
     $manager->flush();
 }
Пример #2
0
 public function isRole(Role $role)
 {
     return $this->role->getId() == $role->getId();
 }