Exemplo n.º 1
0
 /**
  * @Template
  *
  * @param  \ServerGrove\KbBundle\Document\Article  $article
  * @param  \ServerGrove\KbBundle\Document\Category $category
  * @return array
  */
 public function articleContentAction(Article $article, Category $category = null, $showComments = true)
 {
     !is_null($category) || ($category = $article->getDefaultCategory());
     $locales = $this->getActiveLocales($article, $this->getDocumentManager()->getLocalesFor($article));
     $localeNames = $this->getLocaleNames($locales);
     $currentLocale = $this->getRequest()->getLocale();
     foreach ($locales as $locale) {
         $localeNames[$locale]['current'] = $currentLocale == $locale;
         $localeNames[$locale]['path'] = $this->generateUrl('sgkb_articles_view', array('_format' => $this->getRequest()->get('_format'), '_locale' => $locale, 'slug' => $article->getSlug(), 'path' => $category->getPath()));
     }
     $article = $this->getDocumentManager()->refresh($article);
     $this->checkLocale($article);
     $articles = $category->getArticles();
     $index = $articles->indexOf($article);
     $container = $this->get('service_container');
     return array('article' => $article, 'category' => $category, 'locales' => $locales, 'localeNames' => $localeNames, 'previousArticle' => $articles->get($index - 1), 'nextArticle' => $articles->get($index + 1), 'enable_related_urls' => $container->getParameter('server_grove_kb.article.enable_related_urls'), 'showComments' => $showComments);
 }