コード例 #1
0
ファイル: Trees.php プロジェクト: trejjam/authorization
 public function registerRole(Role $role, $connect = TRUE)
 {
     $this->roles[$role->getId()] = $role;
     if ($connect) {
         $role->connectToParent($this->roles);
         if (!$role->hasParent()) {
             $this->rootRoles[$role->getId()] = $role;
         }
     }
 }
コード例 #2
0
ファイル: Role.php プロジェクト: trejjam/authorization
 protected function drawRole(OutputInterface $output, Trejjam\Authorization\Acl\Role $role, $depth = 0)
 {
     $output->writeln(Nette\Utils\Strings::padLeft('', $depth, ' ') . '\\_ ' . $role->getName());
     $resource = [];
     /** @var Trejjam\Authorization\Acl\Resource $v */
     foreach ($role->getResource() as $v) {
         $resource[] = $v->getNameRaw() . ":" . $v->getActionRaw();
     }
     if (count($resource) > 0) {
         $output->writeln(Nette\Utils\Strings::padLeft('', $depth + 2, ' ') . "-" . implode(", ", $resource));
     }
     /** @var Trejjam\Authorization\Acl\Role $v */
     foreach ($role->getChild() as $v) {
         $this->drawRole($output, $v, $depth + 1);
     }
 }
コード例 #3
0
ファイル: Acl.php プロジェクト: trejjam/authorization
 protected function findCircle(Role $role, Role $parent)
 {
     if ($role->getId() == $parent->getId()) {
         return TRUE;
     } else {
         if ($parent->hasParent()) {
             return $this->findCircle($role, $parent->getParent());
         } else {
             return FALSE;
         }
     }
 }
コード例 #4
0
ファイル: Role.php プロジェクト: trejjam/authorization
 /**
  * @param Role $role
  */
 protected function connectToChild(Role $role)
 {
     $this->child[$role->getId()] = $role;
 }
コード例 #5
0
ファイル: Resource.php プロジェクト: trejjam/authorization
 /**
  * @param Role[] $roles
  */
 public function connectToRole($roles)
 {
     $this->role = $roles[$this->roleId];
     $this->role->addResource($this);
 }