/** * @param int|null $id * @param Request $request * * @return RedirectResponse|Response */ public function formAction($id, Request $request) { if (is_null($id)) { throw new RouteNotFoundException(); } return parent::formAction($id, $request); }
/** * @param Form $form * * @throws \Doctrine\ORM\ORMException */ protected function persistData(Form $form) { parent::persistData($form); $positionData = $form->get('tabs')->get('position_tab')->get('position')->getNormData(); if ($positionData) { $positionData = json_decode($positionData); /** @var MenuItem $data */ $data = $form->getData(); $entityManager = $this->getDoctrine()->getEntityManager(); /** @var NestedTreeRepository $menuItemRepo */ $menuItemRepo = $this->getDoctrine()->getRepository($this->getEntityName()); $positionData->parent = intval($positionData->parent) ? $positionData->parent : 0; $data->setParent(null); if (intval($positionData->parent) > 0) { $data->setParent($entityManager->getReference($this->getEntityName(), $positionData->parent)); } $menuItemRepo->persistAsFirstChild($data); if ($positionData->position) { $menuItemRepo->moveDown($data, $positionData->position); } $entityManager->flush(); } }
/** * @param int $id * @param Request $request * @param string $type * * @return RedirectResponse */ public function deleteAction($id, Request $request, $type = null) { $this->type = $type; return parent::deleteAction($id, $request); }