. */ namespace SP\Modules\Web\Controllers\Track; use Exception; use JsonException; use SP\Core\Events\Event; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Domain\Core\Acl\UnauthorizedActionException; use SP\Domain\Core\Exceptions\SPException; use SP\Domain\Http\Dtos\JsonMessage; use SP\Modules\Web\Controllers\Traits\JsonTrait; /** * Class UnlockController * * @package SP\Modules\Web\Controllers */ final class UnlockController extends TrackBase { use JsonTrait; /** * Unlocks a track * * @param int $id * * @return bool * @throws JsonException */ public function unlockAction(int $id): ?bool { try { if (!$this->acl->checkUserAccess(AclActionsInterface::TRACK_UNLOCK)) { throw new UnauthorizedActionException(SPException::ERROR); } $this->trackService->unlock($id); $this->eventDispatcher->notify('unlock.track', new Event($this)); return $this->returnJsonResponse(JsonMessage::JSON_SUCCESS, __u('Track unlocked')); } catch (Exception $e) { processException($e); $this->eventDispatcher->notify('exception', new Event($e)); return $this->returnJsonResponseException($e); } } }