/**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $parent = $form->getParent()->getParent()->getParent();
     $parentData = $parent->getData();
     if ($parentData instanceof AclPrivilege) {
         $view->vars['identity'] = $parentData->getIdentity()->getId();
         $view->vars['level_label'] = AccessLevel::getAccessLevelName($form->getData());
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $parent = $form->getParent()->getParent()->getParent();
     $parentData = $parent->getData();
     if ($parentData instanceof AclPrivilege) {
         $view->vars['identity'] = $parentData->getIdentity()->getId();
         $view->vars['level_label'] = AccessLevel::getAccessLevelName($form->getData());
     }
     //uses on view page for rendering preloaded string (role permission name)
     $view->vars['translation_prefix'] = $this->roleTranslationPrefixResolver->getPrefix();
 }
 /**
  * {@inheritdoc}
  */
 public function getAccessLevelNames()
 {
     if (!$this->hasOwner()) {
         return [AccessLevel::NONE_LEVEL => AccessLevel::NONE_LEVEL_NAME, AccessLevel::SYSTEM_LEVEL => AccessLevel::getAccessLevelName(AccessLevel::SYSTEM_LEVEL)];
     }
     if ($this->isBasicLevelOwned()) {
         $maxLevel = AccessLevel::LOCAL_LEVEL;
         $minLevel = AccessLevel::BASIC_LEVEL;
     } elseif ($this->isLocalLevelOwned()) {
         $maxLevel = AccessLevel::LOCAL_LEVEL;
         $minLevel = AccessLevel::LOCAL_LEVEL;
     } else {
         throw new \BadMethodCallException(sprintf('Owner type %s is not supported', $this->ownerType));
     }
     return AccessLevel::getAccessLevelNames($minLevel, $maxLevel);
 }
Exemplo n.º 4
0
 /**
  * Gets a list of masks from permissions given in $permissions argument
  *
  * @param ArrayCollection|AclPermission[] $permissions
  * @param AclExtensionInterface $extension
  * @param MaskBuilder[] $maskBuilders
  * @return int[]
  */
 protected function getPermissionMasks($permissions, AclExtensionInterface $extension, array $maskBuilders)
 {
     $masks = array();
     foreach ($maskBuilders as $maskBuilder) {
         $maskBuilder->reset();
     }
     foreach ($permissions as $permission) {
         $maskBuilder = $maskBuilders[$permission->getName()];
         $accessLevelName = AccessLevel::getAccessLevelName($permission->getAccessLevel());
         if ($accessLevelName !== null) {
             $maskName = 'MASK_' . $permission->getName() . '_' . $accessLevelName;
             // check if a mask builder supports access levels
             if (!$maskBuilder->hasConst($maskName)) {
                 // remove access level name from the mask name if a mask builder do not support access levels
                 $maskName = 'MASK_' . $permission->getName();
             }
             $maskBuilder->add($maskBuilder->getConst($maskName));
         }
         $masks[$extension->getServiceBits($maskBuilder->get())] = $maskBuilder->get();
     }
     return array_values($masks);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function getAccessLevelNames()
 {
     if (!$this->hasOwner()) {
         return [AccessLevel::NONE_LEVEL => AccessLevel::NONE_LEVEL_NAME, AccessLevel::SYSTEM_LEVEL => AccessLevel::getAccessLevelName(AccessLevel::SYSTEM_LEVEL)];
     }
     $minLevel = AccessLevel::BASIC_LEVEL;
     $maxLevel = AccessLevel::SYSTEM_LEVEL;
     if ($this->isBasicLevelOwned()) {
         $minLevel = AccessLevel::BASIC_LEVEL;
         $maxLevel = AccessLevel::GLOBAL_LEVEL;
     } elseif ($this->isLocalLevelOwned()) {
         $minLevel = AccessLevel::LOCAL_LEVEL;
         $maxLevel = AccessLevel::GLOBAL_LEVEL;
     } elseif ($this->isGlobalLevelOwned()) {
         $minLevel = AccessLevel::GLOBAL_LEVEL;
         $maxLevel = AccessLevel::GLOBAL_LEVEL;
     }
     return AccessLevel::getAccessLevelNames($minLevel, $maxLevel);
 }
 /**
  * @return array
  */
 public function getAccessLevelNamesDataProvider()
 {
     return ['no owner' => ['arguments' => [], 'levels' => [0 => AccessLevel::NONE_LEVEL_NAME]], 'basic level owned' => ['arguments' => ['FRONTEND_USER', 'owner', 'owner_id'], 'levels' => [0 => AccessLevel::NONE_LEVEL_NAME, 1 => AccessLevel::getAccessLevelName(1), 2 => AccessLevel::getAccessLevelName(2)]], 'local level owned' => ['arguments' => ['FRONTEND_CUSTOMER', 'owner', 'owner_id'], 'levels' => [0 => AccessLevel::NONE_LEVEL_NAME, 2 => AccessLevel::getAccessLevelName(2)]]];
 }
Exemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function getAccessLevelNames($object)
 {
     $minLevel = AccessLevel::BASIC_LEVEL;
     $maxLevel = AccessLevel::SYSTEM_LEVEL;
     if ($this->getObjectClassName($object) === ObjectIdentityFactory::ROOT_IDENTITY_TYPE) {
         /**
          * In community version root entity should not have GLOBAL(Organization) access level
          */
         return AccessLevel::getAccessLevelNames($minLevel, $maxLevel, [AccessLevel::GLOBAL_LEVEL]);
     } else {
         $metadata = $this->getMetadata($object);
         if (!$metadata->hasOwner()) {
             return array(AccessLevel::NONE_LEVEL => AccessLevel::NONE_LEVEL_NAME, AccessLevel::SYSTEM_LEVEL => AccessLevel::getAccessLevelName(AccessLevel::SYSTEM_LEVEL));
         }
         if ($metadata->isUserOwned()) {
             $maxLevel = AccessLevel::GLOBAL_LEVEL;
             $minLevel = AccessLevel::BASIC_LEVEL;
         } elseif ($metadata->isBusinessUnitOwned()) {
             $maxLevel = AccessLevel::GLOBAL_LEVEL;
             $minLevel = AccessLevel::LOCAL_LEVEL;
         } elseif ($metadata->isOrganizationOwned()) {
             $maxLevel = AccessLevel::GLOBAL_LEVEL;
             $minLevel = AccessLevel::GLOBAL_LEVEL;
         }
     }
     return AccessLevel::getAccessLevelNames($minLevel, $maxLevel);
 }
 /**
  * {@inheritdoc}
  */
 public function getAccessLevelNames($object)
 {
     return array(AccessLevel::NONE_LEVEL => AccessLevel::NONE_LEVEL_NAME, AccessLevel::SYSTEM_LEVEL => AccessLevel::getAccessLevelName(AccessLevel::SYSTEM_LEVEL));
 }
 /**
  * {@inheritdoc}
  */
 public function getAccessLevelNames($object)
 {
     if ($this->getObjectClassName($object) === ObjectIdentityFactory::ROOT_IDENTITY_TYPE) {
         $minLevel = AccessLevel::BASIC_LEVEL;
     } else {
         $metadata = $this->getMetadata($object);
         if (!$metadata->hasOwner()) {
             return array(AccessLevel::NONE_LEVEL => AccessLevel::NONE_LEVEL_NAME, AccessLevel::SYSTEM_LEVEL => AccessLevel::getAccessLevelName(AccessLevel::SYSTEM_LEVEL));
         }
         if ($metadata->isUserOwned()) {
             $minLevel = AccessLevel::BASIC_LEVEL;
         } elseif ($metadata->isBusinessUnitOwned()) {
             $minLevel = AccessLevel::DEEP_LEVEL;
         } elseif ($metadata->isOrganizationOwned()) {
             $minLevel = AccessLevel::GLOBAL_LEVEL;
         }
     }
     return AccessLevel::getAccessLevelNames($minLevel);
 }
Exemplo n.º 10
0
 /**
  * @return array
  */
 public function getAccessLevelNamesDataProvider()
 {
     return ['no owner' => ['arguments' => [], 'levels' => [0 => AccessLevel::NONE_LEVEL_NAME, 5 => AccessLevel::getAccessLevelName(5)]], 'basic level owned' => ['arguments' => ['USER', 'owner', 'owner_id'], 'levels' => [0 => AccessLevel::NONE_LEVEL_NAME, 1 => AccessLevel::getAccessLevelName(1), 2 => AccessLevel::getAccessLevelName(2), 3 => AccessLevel::getAccessLevelName(3), 4 => AccessLevel::getAccessLevelName(4)]], 'local level owned' => ['arguments' => ['BUSINESS_UNIT', 'owner', 'owner_id'], 'levels' => [0 => AccessLevel::NONE_LEVEL_NAME, 2 => AccessLevel::getAccessLevelName(2), 3 => AccessLevel::getAccessLevelName(3), 4 => AccessLevel::getAccessLevelName(4)]], 'global level owned' => ['arguments' => ['ORGANIZATION', 'owner', 'owner_id'], 'levels' => [0 => AccessLevel::NONE_LEVEL_NAME, 4 => AccessLevel::getAccessLevelName(4)]]];
 }