/** * Page delete. * * @param Article $article * * @return JsonResponse * @Route("/{id}/delete", name="victoire_core_article_delete") * @Template() * @ParamConverter("article", class="VictoireBlogBundle:Article") */ public function deleteAction(Article $article) { $bep = $this->get('victoire_page.page_helper')->findPageByParameters(['templateId' => $article->getTemplate()->getId(), 'entityId' => $article->getId()]); $blogViewReference = $this->container->get('victoire_view_reference.repository')->getOneReferenceByParameters(['viewId' => $article->getBlog()->getId()]); $this->get('victoire_blog.manager.article')->delete($article, $bep); $message = $this->get('translator')->trans('victoire.blog.article.delete.success', [], 'victoire'); $this->get('session')->getFlashBag()->add('success', $message); $response = ['success' => true, 'url' => $this->generateUrl('victoire_core_page_show', ['url' => $blogViewReference->getUrl()]), 'message' => $message]; return new JsonResponse($response); }
/** * Page delete * * @param Article $article * * @return JsonResponse * @Route("/{id}/delete", name="victoire_core_article_delete") * @Template() * @ParamConverter("article", class="VictoireBlogBundle:Article") */ public function deleteAction(Article $article) { $bep = $this->get('victoire_page.page_helper')->findPageByParameters(array('patternId' => $article->getPattern()->getId(), 'entityId' => $article->getId())); $this->get('victoire_blog.manager.article')->delete($article, $bep); //redirect to the homepage $homepageUrl = $this->generateUrl('victoire_core_page_show', array('_locale' => $article->getBlog()->getLocale(), 'url' => $article->getBlog()->getUrl())); $message = $this->get('translator')->trans('victoire.blog.article.delete.success', array(), 'victoire'); $this->get('session')->getFlashBag()->add('success', $message); $response = array('success' => true, 'url' => $homepageUrl, 'message' => $message); return new JsonResponse($response); }