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();
 }
 /**
  * @FosRest\Delete("/{category}", requirements={"category" = "\d+"})
  *
  * @ParamConverter("category", class="MainBundle:Category")
  *
  * @FosRest\View()
  * @param Category $category
  */
 public function removeAction(Category $category)
 {
     $this->checkPermissionsForSection($category->getGuide()->getSection());
     return $this->get('main.category.service')->removeCategory($category);
 }