コード例 #1
0
 public function getModel(Category $category)
 {
     return (new CategoryModel())->setId($category->getId())->setPosition($category->getPosition())->setTitle($category->getTitle())->setImage($category->getImage())->setContent($category->getContent());
 }
コード例 #2
0
 public function removeCategory(Category $category)
 {
     $oldSiblings = $category->getParent() ? $category->getParent()->getChildren() : $category->getGuide()->getCategoriesWithoutParent();
     foreach ($oldSiblings as $child) {
         if ($child->getPosition() >= $category->getPosition()) {
             $child->setPosition($child->getPosition() - 1);
         }
         $this->em->persist($child);
     }
     $this->em->remove($category);
     $this->em->flush();
 }