/**
* 위젯박스를 생성한다.
*
* @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;
}