public function indexAction(Request $request, $nodeId) { $node = $this->responseHelper->getNodeOr404($nodeId); if (false === $this->routerHelper->hasController($node->getType())) { throw new NotFoundHttpException('Node don\'t have controller.'); } $form = $this->formFactory->create($node); $jsonContent = $this->responseHelper->createJsonContent($node); $messages = new Messages(); if ($this->formHandler->process($request, $form)) { $message = $this->formHandler->onSuccess($request->getLocale(), $node); $messages->addSuccess($message); if ('json' === $request->getRequestFormat()) { $jsonContent->setToolbar($this->renderToolbar($node)); } // Hack... Form with new data. $form = $this->formFactory->create($node); } if ('json' === $request->getRequestFormat()) { $jsonContent->setMessages($this->responseHelper->renderMessages($messages)); $jsonContent->setTab($this->renderNodeRoute($form)); return $this->responseHelper->getJsonResponse($jsonContent); } return new Response($this->renderNodeRoute($form, $messages)); }
public function indexAction(Request $request, $nodeId) { $node = $this->responseHelper->getNodeOr404($nodeId); $messages = new Messages(); $form = $this->formFactory->create($node); if ($this->formHandler->process($request, $form)) { $messages->addSuccess($this->formHandler->onSuccess($request->getLocale(), $node)); } if ('json' === $request->getRequestFormat()) { $jsonContent = $this->responseHelper->createJsonContent($node); $jsonContent->setMessages($this->responseHelper->renderMessages($messages)); $jsonContent->setTab($this->renderNodeSeoForm($form)); return $this->responseHelper->getJsonResponse($jsonContent); } return new Response($this->renderNodeSeoForm($form, $messages)); }
public function indexAction(Request $request, $nodeId) { $node = $this->responseHelper->getNodeOr404($nodeId); if ('redirect' !== $node->getType()) { throw new NotFoundHttpException('Node type is not redirect!'); } $form = $this->formFactory->create($node); $jsonContent = $this->responseHelper->createJsonContent($node); $messages = new Messages(); if ($this->formHandler->process($request, $form)) { $message = $this->formHandler->onSuccess($request->getLocale(), $node); $messages->addSuccess($message); // Hack... Form with new data. $form = $this->formFactory->create($node); } if ('json' === $request->getRequestFormat()) { $jsonContent->setMessages($this->responseHelper->renderMessages($messages)); $jsonContent->setTab($this->renderNodeRedirectRoute($form)); return $this->responseHelper->getJsonResponse($jsonContent); } return new Response($this->renderNodeRedirectRoute($form, $messages)); }
/** * Sitemap tree node delete action. * * @param Request $request * @param int $nodeId * * @return Response */ public function deleteAction(Request $request, $nodeId) { $node = $this->responseHelper->getNodeOr404($nodeId); $jsonContent = $this->responseHelper->createJsonContent($node); if ($this->nodeDeleteHandler->process($node, $request)) { $messages = new Messages(); $messages->addSuccess($this->nodeDeleteHandler->onSuccess($request->getLocale(), $node)); if ('json' === $request->getRequestFormat()) { $jsonContent->setMessages($this->responseHelper->renderMessages($messages)); return $this->responseHelper->getJsonResponse($jsonContent); } return new Response($this->responseHelper->renderMessages($messages)); } if ('json' === $request->getRequestFormat()) { $jsonContent->setContent($this->renderNodeDeleteConfirm($node)); return $this->responseHelper->getJsonResponse($jsonContent); } return new Response($this->renderNodeDeleteConfirm($node)); }