. */ namespace SP\Modules\Web\Controllers\PublicLink; use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Exceptions\ValidationException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; /** * Class SaveCreate */ final class SaveCreate extends PublicLinkSaveBase { use JsonTrait; /** * @return bool * @throws \JsonException */ public function saveCreateAction(): bool { try { if (!$this->acl->checkUserAccess(ActionsInterface::PUBLICLINK_CREATE)) { return $this->returnJsonResponse( JsonResponse::JSON_ERROR, __u('You don\'t have permission to do this operation') ); } $this->form->validateFor(ActionsInterface::PUBLICLINK_CREATE); $this->publicLinkService->create($this->form->getItemData()); $this->eventDispatcher->notifyEvent('create.publicLink', new Event($this)); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Link created')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent( 'exception', new Event($e) ); return $this->returnJsonResponseException($e); } } }