Пример #1
0
 /**
  * @param int $id
  * @param string $action
  *
  * @return array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id, $action = '')
 {
     return $this->actionHelper->handleCustomDeleteAction($action, function (array $items) use($id) {
         $result = $this->commentsModel->delete($items);
         // If there are no comments for the given module, redirect to the general comments admin panel page
         if ($this->commentRepository->countAll($id) == 0) {
             $redirectUrl = 'acp/comments';
         } else {
             $redirectUrl = 'acp/comments/details/index/id_' . $id;
         }
         return $this->redirectMessages()->setMessage($result, $this->translator->t('system', $result !== false ? 'delete_success' : 'delete_error'), $redirectUrl);
     }, 'acp/comments/details/delete/id_' . $id, 'acp/comments/details/index/id_' . $id);
 }