. */ namespace SP\Modules\Api\Controllers\Client; use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Domain\Api\Dtos\ApiResponse; use SP\Domain\Core\Acl\AclActionsInterface; /** * Class DeleteController */ final class DeleteController extends ClientBase { /** * deleteAction */ public function deleteAction(): void { try { $this->setupApi(AclActionsInterface::CLIENT_DELETE); $id = $this->apiService->getParamInt('id', true); $clientData = $this->clientService->getById($id); $this->clientService->delete($id); $this->eventDispatcher->notify( 'delete.client', new Event( $this, EventMessage::factory() ->addDescription(__u('Client deleted')) ->addDetail(__u('Name'), $clientData->getName()) ->addDetail('ID', $id) ) ); $this->returnResponse(ApiResponse::makeSuccess($clientData, $id, __('Client deleted'))); } catch (Exception $e) { $this->returnResponseException($e); processException($e); } } }