/**
  * Adds the given new comment object to the comment repository
  *
  * @Flow\Validate(type="\Lelesys\Captcha\Validators\CaptchaValidator", value="$captcha")
  * @Flow\Validate(type="NotEmpty", value="$captcha")
  * @param \Lelesys\Plugin\News\Domain\Model\Comment $newComment A new comment to add
  * @param \Lelesys\Plugin\News\Domain\Model\News $news
  * @param string $captcha Captcha for comment
  * @return void
  */
 public function createAction(\Lelesys\Plugin\News\Domain\Model\Comment $newComment, \Lelesys\Plugin\News\Domain\Model\News $news, $captcha = NULL)
 {
     try {
         $this->commentService->create($newComment, $news);
         $array = array("news" => $news);
         $this->addFlashMessage($this->translator->translateById('lelesys.plugin.news.comment.created', array(), NULL, NULL, 'Main', $this->settings['flashMessage']['packageKey']));
         $this->redirect("show", "News", "Lelesys.Plugin.News", $array);
     } catch (Lelesys\Plugin\News\Domain\Service\Exception $exception) {
         $packageKey = $this->settings['flashMessage']['packageKey'];
         $header = 'Sorry, error occured. Please try again later.';
         $message = $this->translator->translateById('lelesys.plugin.news.try.again', array(), NULL, NULL, 'Main', $packageKey);
         $this->addFlashMessage($message, $header, \TYPO3\Flow\Error\Message::SEVERITY_ERROR);
     }
 }
 /**
  * show's the hidden category
  *
  * @param \Lelesys\Plugin\News\Domain\Model\Comment $comment
  * @return void
  */
 public function publishAction(\Lelesys\Plugin\News\Domain\Model\Comment $comment)
 {
     try {
         $this->commentService->publishComment($comment);
         $packageKey = $this->settings['flashMessage']['packageKey'];
         $header = 'Comment is published.';
         $message = $this->translator->translateById('lelesys.plugin.news.publish.comment', array(), NULL, NULL, 'Main', $packageKey);
         $this->addFlashMessage($message, $header, \TYPO3\Flow\Error\Message::SEVERITY_OK);
         $this->redirect('index');
     } catch (Lelesys\NeoNews\Domain\Service\Exception $exception) {
         $packageKey = $this->settings['flashMessage']['packageKey'];
         $header = 'Sorry, error occured. Please try again later.';
         $message = $this->translator->translateById('lelesys.plugin.news.try.again', array(), NULL, NULL, 'Main', $packageKey);
         $this->addFlashMessage($message, $header, \TYPO3\Flow\Error\Message::SEVERITY_ERROR);
     }
 }
 /**
  * Shows a list of latest news
  *
  * @return void
  */
 public function latestNewsAction()
 {
     $currentNode = $this->request->getInternalArgument('__node');
     $pluginArguments = $currentNode->getProperties();
     if ($this->request->hasArgument('newsBySelection')) {
         $nodeArgument = $this->request->getArgument('newsBySelection');
         $currentNode->setProperty('categoryId', $nodeArgument['category']);
         $currentNode->setProperty('folderId', $nodeArgument['folder']);
     }
     $categoryId = $currentNode->getProperty('categoryId');
     $folderId = $currentNode->getProperty('folderId');
     $this->view->assign('folderId', $folderId);
     $this->view->assign('categoryId', $categoryId);
     $category = NULL;
     $folder = NULL;
     if ($categoryId !== NULL) {
         $category = $categoryId;
     }
     if ($folderId !== NULL) {
         $folder = $folderId;
     }
     $allNews = $this->newsService->listAllBySelection($category, $folder, $pluginArguments);
     $this->view->assign('newsLatestComments', $this->commentService->getEnabledComments($allNews));
     $this->view->assign('categories', $this->categoryService->getEnabledLatestCategories());
     $this->view->assign('folders', $this->folderService->listAll());
     $this->view->assign('allNews', $allNews);
     $this->view->assign('assetsForNews', $this->newsService->assetsForNews($allNews));
     $this->view->assign('baseUri', $this->bootstrap->getActiveRequestHandler()->getHttpRequest()->getBaseUri());
 }