/**
  * create instance
  *
  * @param Permissions   $permissions   permission factory instance
  * @param Assignor      $assignor      assignor
  * @param Action        $action        action
  * @param ConfigHandler $configHandler config handler
  */
 public function __construct(Permissions $permissions, Assignor $assignor, Action $action, ConfigHandler $configHandler)
 {
     $this->permissions = $permissions;
     $this->assignor = $assignor;
     $this->action = $action;
     $this->configHandler = $configHandler;
     $this->action->add(self::ACTION_LIST);
     $this->action->add(self::ACTION_MANAGE);
 }
示例#2
0
 /**
  * Set grant information
  *
  * @param string       $action action type
  * @param string|array $type   value type
  * @param mixed        $value  values
  * @return $this
  * @throws InvalidArgumentException
  */
 public function set($action, $type, $value = null)
 {
     if (array_key_exists($action, Action::all()) === false) {
         throw new InvalidArgumentException(['name' => 'action', 'value' => $action]);
     }
     $this->attributes[$action] = $this->makeValue($type, $value);
     return $this;
 }
示例#3
0
 /**
  * 요청한 action 을 현재 permission 에서 체크 가능한지 여부 판별
  *
  * @param string $action action keyword
  * @return bool
  */
 protected function support($action)
 {
     return array_search($action, array_merge($this->actions, Action::all())) !== false;
 }