public function delete(HttpRequest $httpRequest) { $httpResponse = new HttpResponse(); try { $urlParams = $httpRequest->getUrlParams(); $identityProperty = $this->getIdentityProperty($this->entity); if ($urlParams[$identityProperty]) { $this->entity = $this->business->getItem($urlParams[$identityProperty]); } if (!$urlParams[$identityProperty] || !$this->entity) { throw new \Exception(Messages::OBJECT_NOT_FOUND); } if ($httpRequest->getRequest()) { try { $this->business->delete($this->entity); \App::getInstance()->redirect(\App::getInstance()->getURIPrevious(), Messages::OPERATION_SUCCESSFUL); } catch (\core\exception\ValidationException $e) { $this->handleValidationException($e, $httpRequest, $httpResponse); } } $formAnnotations = $this->extractFormAnnotationsFromEntity($this->entity); $formAction = $this->getFormAction($httpRequest); $submitCallback = JavascriptHelper::createAlertConfirm(ucfirst(__FUNCTION__).'?'); $htmlForm = $this->generateHtmlFormDisabled(get_class($this->entity), $formAnnotations, __FUNCTION__, $formAction, $submitCallback, $httpRequest->getPostAjax()); \App::getInstance()->setOutputMessage(Messages::CONFIRM_DELETE); $httpResponse->setContent($htmlForm); return $httpResponse; } catch (\Exception $e) { throw new PresentationException($e); } }