private function addTranslation(ObjectManager $manager, Category $category, $locale, $name, $description)
 {
     $category->setName($name);
     $category->setDescription($description);
     $manager->bindTranslation($category, $locale);
     $manager->flush();
 }
 /**
  * @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;
 }
 /**
  * @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;
 }
 private function createDeleteForm(Category $category)
 {
     return $this->createFormBuilder(array('id' => $category->getId()))->add('id', 'hidden')->getForm();
 }
Beispiel #5
0
 public function removeCategory(Category $category)
 {
     $this->categories->removeElement($category->removeArticle($this));
     return $this;
 }