public function getModel(Category $category) { return (new CategoryModel())->setId($category->getId())->setPosition($category->getPosition())->setTitle($category->getTitle())->setImage($category->getImage())->setContent($category->getContent()); }
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(); }