/** * createAccessGrant * * @param array $inputs to create grant params array * @param Grant $grant if need to add already exist grant this param is not null * * @return Grant * */ protected function createAccessGrant(array $inputs) { $grant = new Grant(); $rating = $inputs['accessRating']; $group = $this->innerParamParsing($inputs['accessGroup']); $user = $this->innerParamParsing($inputs['accessUser']); $except = $this->innerParamParsing($inputs['accessExcept']); $grant->add(Action::ACCESS, 'rating', $rating); $grant->add(Action::ACCESS, 'group', $group); $grant->add(Action::ACCESS, 'user', $user); $grant->add(Action::ACCESS, 'except', $except); return $grant; }
/** * getSampleGrant * * @return Grant */ protected function getSampleGrant() { $grant = new Grant(); $grant->add(Action::ACCESS, 'manager'); $grant->add(Action::ACCESS, 'group', []); $grant->add(Action::ACCESS, 'user', []); $grant->add(Action::ACCESS, 'except', []); return $grant; }
/** * Get default grant * * @return Grant */ public function getDefaultGrant() { $grant = new Grant(); $grant->add(static::ACCESS, 'rating', 'guest'); $grant->add(static::ACCESS, 'group', []); $grant->add(static::ACCESS, 'user', []); $grant->add(static::ACCESS, 'except', []); $grant->add(static::VISIBLE, 'rating', 'guest'); $grant->add(static::VISIBLE, 'group', []); $grant->add(static::VISIBLE, 'user', []); $grant->add(static::VISIBLE, 'except', []); return $grant; }
/** * createAccessGrant * * @param array $inputs to create grant params array * @param Grant $grant if need to add already exist grant this param is not null * * @return Grant * */ public function createVisibleGrant(array $inputs, $grant = null) { if ($grant === null) { $grant = new Grant(); } if (isset($inputs['visibleMode']) && $inputs['visibleMode'] === 'inherit') { return $grant; } $rating = $inputs['visibleRating']; $group = $this->innerParamParsing($inputs['visibleGroup']); $user = $this->innerParamParsing($inputs['visibleUser']); $except = $this->innerParamParsing($inputs['visibleExcept']); $grant->add(Action::VISIBLE, 'rating', $rating); $grant->add(Action::VISIBLE, 'group', $group); $grant->add(Action::VISIBLE, 'user', $user); $grant->add(Action::VISIBLE, 'except', $except); return $grant; }
/** * grant 를 생성해서 반환 * * @param Grant $grant grant instance * @param string $action action name * @param array $permissions permissions * @return Grant */ public function createGrant(Grant $grant, $action, $permissions) { foreach ($permissions as $type => $value) { $grant->add($action, $type, $value); } return $grant; }