register() public method

Register permission information
public register ( string $name, Grant $grant, string $siteKey = 'default' ) : Permission
$name string permission name
$grant Grant grant instance
$siteKey string site key name
return Permission
 /**
  * 위젯박스를 생성한다.
  *
  * @param array $data 생성할 위젯박스의 데이터
  *
  * @return void
  */
 public function create($data)
 {
     $id = array_get($data, 'id');
     if ($id === null) {
         throw new IDNotFoundException();
     }
     if (str_contains($id, '.')) {
         throw new InvalidIDException();
     }
     if ($this->repository->find($id) !== null) {
         throw new IDAlreadyExistsException();
     }
     $options = array_get($data, 'options', []);
     if (is_array($options)) {
         $options = json_encode($options);
     }
     $title = array_get($data, 'title', $id);
     $content = array_get($data, 'content', '');
     $widgetbox = $this->repository->create(compact('id', 'title', 'content', 'options'));
     $grant = new Grant();
     $grant->set('edit', [Grant::RATING_TYPE => Rating::SUPER, Grant::GROUP_TYPE => [], Grant::USER_TYPE => [], Grant::EXCEPT_TYPE => []]);
     $this->permissionHandler->register('widgetbox.' . $id, $grant);
     return $widgetbox;
 }
 /**
  * 게시판 기본 권한 반환
  * install 시 설정 하기 위한 기본 권한
  *
  * @return Grant
  */
 public function addGlobal()
 {
     $grant = new Grant();
     foreach ($this->actions as $action) {
         if ($action == self::ACTION_MANAGE) {
             $perm = [Grant::RATING_TYPE => 'manager', Grant::GROUP_TYPE => [], Grant::USER_TYPE => [], Grant::EXCEPT_TYPE => []];
         } elseif ($action == self::ACTION_LIST || $action == self::ACTION_READ) {
             $perm = [Grant::RATING_TYPE => 'guest', Grant::GROUP_TYPE => [], Grant::USER_TYPE => [], Grant::EXCEPT_TYPE => []];
         } else {
             $perm = [Grant::RATING_TYPE => 'member', Grant::GROUP_TYPE => [], Grant::USER_TYPE => [], Grant::EXCEPT_TYPE => []];
         }
         $grant = $this->addGrant($grant, $action, $perm);
     }
     $this->permissionHandler->register($this->getPrefix(), $grant);
     return $grant;
 }
 public function testRegisterExecutedInsertWhenNotExists()
 {
     list($repo) = $this->getMocks();
     $instance = new PermissionHandler($repo);
     $grant = new Grant();
     $grant->set('access', 'guest');
     $grant->set('delete', 'group', ['group_id_1', 'group_id_2']);
     $mockPermission = m::mock('Xpressengine\\Permission\\Permission');
     $mockParent = m::mock('Xpressengine\\Permission\\Permission');
     $mockParent->shouldReceive('get')->with('siteKey')->andReturn('default');
     $mockParent->shouldReceive('get')->with('name')->andReturn('plugin');
     $repo->shouldReceive('findByName')->once()->with('default', 'plugin.dummy')->andReturnNull();
     $repo->shouldReceive('fetchAncestor')->once()->andReturn([$mockParent]);
     $repo->shouldReceive('insert')->once()->with(m::on(function ($value) {
         return $value instanceof Permission;
     }))->andReturn($mockPermission);
     $instance->register('plugin.dummy', $grant, 'default');
 }
 public function updatePermission(PermissionHandler $permissionHandler, Request $request, $permissionId)
 {
     $permissionHandler->register($permissionId, $this->createAccessGrant($request->only(['accessRating', 'accessGroup', 'accessUser', 'accessExcept'])));
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }