set() public method

Set grant information
public set ( string $action, string | array $type, mixed $value = null )
$action string action type
$type string | array value type
$value mixed values
 public function init()
 {
     app('xe.config')->set(EditorHandler::CONFIG_NAME, ['height' => 400, 'fontSize' => '14px', 'fontFamily' => null, 'uploadActive' => true, 'fileMaxSize' => 2, 'attachMaxSize' => 10, 'extensions' => '*', 'tools' => []]);
     $data = [Grant::RATING_TYPE => Rating::MEMBER, Grant::GROUP_TYPE => [], Grant::USER_TYPE => [], Grant::EXCEPT_TYPE => [], Grant::VGROUP_TYPE => []];
     $grant = new Grant();
     $grant->set('html', $data);
     $grant->set('tool', $data);
     $grant->set('upload', $data);
     $grant->set('download', $data);
     app('xe.permission')->register(EditorHandler::CONFIG_NAME, $grant);
 }
 public function testRegisterExecutedUpdateWhenNotExists()
 {
     list($repo) = $this->getMocks();
     $instance = m::mock('Xpressengine\\Permission\\PermissionHandler[getOrNew]', [$repo])->shouldAllowMockingProtectedMethods();
     $grant = new Grant();
     $grant->set('access', 'guest');
     $grant->set('delete', 'group', ['group_id_1', 'group_id_2']);
     $mockParent = m::mock('Xpressengine\\Permission\\Permission');
     $mockParent->shouldReceive('get')->with('siteKey')->andReturn('default');
     $mockParent->shouldReceive('get')->with('name')->andReturn('plugin');
     $mockPermission = m::mock('Xpressengine\\Permission\\Permission');
     $mockPermission->exists = true;
     $mockPermission->shouldReceive('setGrant')->once()->with($grant)->andReturnNull();
     $instance->shouldReceive('getOrNew')->once()->with('plugin.dummy', 'default')->andReturn($mockPermission);
     $repo->shouldReceive('update')->once()->with($mockPermission)->andReturn($mockPermission);
     $instance->register('plugin.dummy', $grant, 'default');
 }
 /**
  * Register permission
  *
  * @param Request      $request   request instance
  * @param string       $key       permission key
  * @param array|string $abilities abilities
  * @param string       $siteKey   site key
  * @return void
  */
 public function permissionRegister(Request $request, $key, $abilities, $siteKey = 'default')
 {
     $abilities = !is_array($abilities) ? [$abilities] : $abilities;
     $grant = new Grant();
     foreach ($abilities as $ability) {
         if ($data = $this->makeGrantData($request, $ability)) {
             $grant->set($ability, $data);
         }
     }
     $this->permissionRegisterGrant($key, $grant, $siteKey);
 }
 /**
  * 위젯박스를 생성한다.
  *
  * @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;
 }
 public function testRegisterExecutedUpdateWhenNotExists()
 {
     list($auth, $routes, $repo) = $this->getMocks();
     $grant = new Grant();
     $grant->set('access', 'guest');
     $grant->set('delete', 'group', ['group_id_1', 'group_id_2']);
     $mockParent = m::mock('Xpressengine\\Permission\\Registered');
     $mockRegistered = m::mock('Xpressengine\\Permission\\Registered');
     $mockRegistered->shouldReceive('setGrant')->once()->with($grant)->andReturnNull();
     $mockRegistered->shouldReceive('getOriginal')->once()->andReturn(["access" => ["rating" => "manager", "group" => [], "user" => [], "except" => []]]);
     $mockRegistered->shouldReceive('addParent')->once()->with($mockParent);
     $repo->shouldReceive('findByTypeAndName')->once()->with('default', 'instance', 'plugin.dummy')->andReturn($mockRegistered);
     $repo->shouldReceive('fetchAncestor')->once()->andReturn([$mockParent]);
     $repo->shouldReceive('update')->once()->with($mockRegistered)->andReturn($mockRegistered);
     $instance = new Factory($auth, $routes, $repo);
     $instance->register('instance', 'plugin.dummy', $grant);
 }