Esempio n. 1
0
 protected function setupRoles(Role $role)
 {
     if ($role->hasChild()) {
         $parents = [];
         foreach ($role->getChild() as $v) {
             $this->setupRoles($v);
             $parents[] = $v->getName();
         }
         $this->addRole($role->getName(), $parents);
     } else {
         $this->addRole($role->getName());
     }
 }
Esempio n. 2
0
 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);
     }
 }