Esempio n. 1
0
 /**
  * @param \Symfony\Component\Form\FormBuilderInterface $builder
  *
  * @return $this
  */
 protected function addTitleField(FormBuilderInterface $builder)
 {
     $builder->add(self::FIELD_TITLE, 'text', ['label' => 'Title', 'constraints' => [new NotBlank(), new Callback(['methods' => [function ($name, ExecutionContextInterface $contextInterface) {
         if ($this->queryContainer->queryGroupByName($name)->count() > 0) {
             $contextInterface->addViolation('Group name already in use');
         }
     }], 'groups' => [self::GROUP_UNIQUE_GROUP_CHECK]])]]);
     return $this;
 }
Esempio n. 2
0
 /**
  * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config
  *
  * @return array
  */
 protected function prepareData(TableConfiguration $config)
 {
     $roleQuery = $this->aclQueryContainer->queryRole();
     $queryResults = $this->runQuery($roleQuery, $config);
     $results = [];
     foreach ($queryResults as $rule) {
         $results[] = [SpyAclRoleTableMap::COL_CREATED_AT => $this->dateFormatter->dateTime($rule[SpyAclRoleTableMap::COL_CREATED_AT]), SpyAclRoleTableMap::COL_NAME => $rule[SpyAclRoleTableMap::COL_NAME], self::ACTION => implode(' ', $this->createTableActions($rule))];
     }
     return $results;
 }
Esempio n. 3
0
 /**
  * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config
  *
  * @return array
  */
 protected function prepareData(TableConfiguration $config)
 {
     $rulesetQuery = $this->aclQueryContainer->queryRuleByRoleId($this->idRole);
     $queryResults = $this->runQuery($rulesetQuery, $config);
     $results = [];
     foreach ($queryResults as $ruleset) {
         $results[] = [SpyAclRuleTableMap::COL_BUNDLE => $ruleset[SpyAclRuleTableMap::COL_BUNDLE], SpyAclRuleTableMap::COL_CONTROLLER => $ruleset[SpyAclRuleTableMap::COL_CONTROLLER], SpyAclRuleTableMap::COL_ACTION => $ruleset[SpyAclRuleTableMap::COL_ACTION], SpyAclRuleTableMap::COL_TYPE => $ruleset[SpyAclRuleTableMap::COL_TYPE], self::ACTIONS => implode(' ', $this->createTableActions($ruleset))];
     }
     return $results;
 }
Esempio n. 4
0
 /**
  * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config
  *
  * @return array
  */
 protected function prepareData(TableConfiguration $config)
 {
     $query = $this->aclQueryContainer->queryGroupUsers($this->idGroup);
     /** @var \Orm\Zed\User\Persistence\SpyUser[] $userCollection */
     $userCollection = $this->runQuery($query, $config, true);
     $users = [];
     foreach ($userCollection as $user) {
         $users[] = [self::COL_ID_USER => $user->getIdUser(), self::COL_FIRST_NAME => $user->getFirstName(), self::COL_LAST_NAME => $user->getLastName(), self::COL_EMAIL => $user->getUsername(), self::ACTIONS => $this->getRemoveUrl($user)];
     }
     return $users;
 }
Esempio n. 5
0
File: Role.php Progetto: spryker/Acl
 /**
  * @param string $name
  *
  * @return \Generated\Shared\Transfer\RoleTransfer
  */
 public function getByName($name)
 {
     $aclRoleEntity = $this->queryContainer->queryRoleByName($name)->findOne();
     $roleTransfer = new RoleTransfer();
     $roleTransfer->fromArray($aclRoleEntity->toArray(), true);
     return $roleTransfer;
 }
Esempio n. 6
0
File: Rule.php Progetto: spryker/Acl
 /**
  * @param int $id
  *
  * @throws \Spryker\Zed\Acl\Business\Exception\RuleNotFoundException
  *
  * @return bool
  */
 public function removeRuleById($id)
 {
     $aclRuleEntity = $this->queryContainer->queryRuleById($id)->delete();
     if ($aclRuleEntity <= 0) {
         throw new RuleNotFoundException();
     }
     return true;
 }
Esempio n. 7
0
 /**
  * @param int $idGroup
  *
  * @return \Generated\Shared\Transfer\RoleTransfer
  */
 public function getRoles($idGroup)
 {
     $roleCollection = $this->queryContainer->queryGroupRoles($idGroup)->find();
     $roleTransferCollection = new RolesTransfer();
     foreach ($roleCollection as $roleEntity) {
         $roleTransfer = new RoleTransfer();
         $roleTransfer->fromArray($roleEntity->toArray(), true);
         $roleTransferCollection->addRole($roleTransfer);
     }
     return $roleTransferCollection;
 }
Esempio n. 8
0
 /**
  * @return array
  */
 protected function getAvailableRoleList()
 {
     $roleCollection = $this->queryContainer->queryRole()->find()->toArray();
     return array_column($roleCollection, 'Name', 'IdAclRole');
 }