. */ namespace SP\Modules\Web\Controllers\PublicLink; use Exception; use JsonException; use SP\Core\Events\Event; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\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(AclActionsInterface::PUBLICLINK_CREATE)) { return $this->returnJsonResponse( JsonResponse::JSON_ERROR, __u('You don\'t have permission to do this operation') ); } $this->form->validateFor(AclActionsInterface::PUBLICLINK_CREATE); $this->publicLinkService->create($this->form->getItemData()); $this->eventDispatcher->notify('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->notify( 'exception', new Event($e) ); return $this->returnJsonResponseException($e); } } }