commentService = $commentService; } /** * @throws Exception */ public function get($params): Response { if (! isset($params['module'], $params['entitiyId'], $params['entity'])) { throw new Exception('comments module needs to be initialized with module, entity id and entity'); } $this->module = $params['module']; $this->id = $params['entitiyId']; $this->entity = $params['entity']; $comments = $this->commentService->getComments($this->module, $this->id); $this->tpl->assign('numComments', count($comments)); $this->tpl->assign('comments', $comments); // Delete comment if (isset($params['delComment']) === true) { $commentId = (int) ($params['delComment']); if ($this->commentService->deleteComment($commentId)) { $this->tpl->setNotification($this->language->__('notifications.comment_deleted'), 'success'); return Frontcontroller::redirect(BASE_URL.'/tickets/showTicket/'.$this->id); } else { $this->tpl->setNotification($this->language->__('notifications.comment_deleted_error'), 'error'); } } return $this->tpl->displayPartial('comments.showAll'); } /** * @throws BindingResolutionException */ public function post($params): Response { if (isset($params['comment']) === true) { if ($this->commentService->addComment($_POST, $this->module, $this->id, $this->entity)) { $this->tpl->setNotification($this->language->__('notifications.comment_create_success'), 'success'); } else { $this->tpl->setNotification($this->language->__('notifications.comment_create_error'), 'error'); } } return new Response; } }