/**
  * {@inheritdoc}
  */
 public function getRoles()
 {
     $roles = [];
     foreach ($this->pool->getAdminGroups() as $name => $group) {
         if (!isset($group['items'])) {
             continue;
         }
         foreach ($group['items'] as $item) {
             $admin = $this->pool->getInstance($item['admin']);
             $baseRole = $this->securityHandler->getBaseRole($admin);
             $baseName = $admin->getTranslator()->trans($group['label'], [], $group['label_catalogue']) . ': ' . $admin->getTranslator()->trans($admin->getLabel());
             $actions = [];
             foreach ($admin->getSecurityInformation() as $name => $value) {
                 $parts = explode('.', $name);
                 if (count($parts) < 1) {
                     continue;
                 }
                 $actions[] = strtoupper($parts[count($parts) - 1]);
             }
             foreach ($actions as $action) {
                 $roles[sprintf($baseRole, $action)] = $baseName . ': ' . $admin->getTranslator()->trans($action);
             }
         }
     }
     return array_merge($roles, $this->defaultRoles);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function isGranted($name, $object = null)
 {
     $key = md5(json_encode($name) . ($object ? '/' . spl_object_hash($object) : ''));
     if (!array_key_exists($key, $this->cacheIsGranted)) {
         $this->cacheIsGranted[$key] = $this->securityHandler->isGranted($this, $name, $object ?: $this);
     }
     return $this->cacheIsGranted[$key];
 }