Ejemplo n.º 1
0
 private function addTranslation(ObjectManager $manager, Category $category, $locale, $name, $description)
 {
     $category->setName($name);
     $category->setDescription($description);
     $manager->bindTranslation($category, $locale);
     $manager->flush();
 }
Ejemplo n.º 2
0
 /**
  * @param  \ServerGrove\KbBundle\Document\Category      $category
  * @param  \Doctrine\Common\Collections\ArrayCollection $articles
  * @return \Doctrine\Common\Collections\ArrayCollection
  */
 public function getArticlesFromCategoryHierarchy(Category $category, ArrayCollection $articles)
 {
     if (is_null($articles)) {
         $articles = new \Doctrine\Common\Collections\ArrayCollection();
     }
     foreach ($category->getArticles() as $article) {
         $articles->add($article);
     }
     foreach ($category->getChildren() as $child) {
         $this->getArticlesFromCategoryHierarchy($child, $articles);
     }
     return $articles;
 }
Ejemplo n.º 3
0
 /**
  * @param \ServerGrove\KbBundle\Document\Category $category
  *
  * @return bool
  */
 private function shouldCategoryBeDisplayed(Category $category)
 {
     if (0 < $category->getArticles()->count()) {
         /** @var $article \ServerGrove\KbBundle\Document\Article */
         foreach ($category->getArticles() as $article) {
             // If the category has at least one article active,
             // it should be displayed
             if ($article->getIsActive()) {
                 return true;
             }
         }
     } elseif (0 < $category->getChildren()->count()) {
         /** @var $child \ServerGrove\KbBundle\Document\Category */
         foreach ($category->getChildren() as $child) {
             if ($this->shouldCategoryBeDisplayed($child)) {
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 private function createDeleteForm(Category $category)
 {
     return $this->createFormBuilder(array('id' => $category->getId()))->add('id', 'hidden')->getForm();
 }
Ejemplo n.º 5
0
 public function removeCategory(Category $category)
 {
     $this->categories->removeElement($category->removeArticle($this));
     return $this;
 }