/** * BasePage settings * @param BasePage $page * * @Route("/{id}", name="victoire_seo_pageSeo_settings") * @Template() * * @return JsonResponse */ public function settingsAction(BasePage $page) { //services $em = $this->getDoctrine()->getManager(); $businessProperties = array(); //if the page is a business entity template page if ($page instanceof BusinessEntityPage) { //get the id of the business entity $businessEntityId = $page->getBusinessEntityName(); //we can use the business entity properties on the seo $businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId); $businessProperties = $businessEntity->getBusinessPropertiesByType('seoable'); } $pageSeo = $page->getSeo() ? $page->getSeo() : new PageSeo($page); //url for the form $formUrl = $this->container->get('router')->generate('victoire_seo_pageSeo_settings', array('id' => $page->getId())); //create the form $form = $this->container->get('form.factory')->create('seo_page', $pageSeo, array('action' => $formUrl, 'method' => 'POST')); $form->handleRequest($this->get('request')); if ($form->isValid()) { $em->persist($pageSeo); $page->setSeo($pageSeo); $em->persist($page); $em->flush(); //redirect to the page url $pageUrl = $page->getUrl(); $url = $this->generateUrl('victoire_core_page_show', array('url' => $pageUrl)); return new JsonResponse(array('success' => true, 'url' => $url)); } return new JsonResponse(array('success' => false, 'html' => $this->container->get('victoire_templating')->render('VictoireSeoBundle:PageSeo:settings.html.twig', array('page' => $page, 'form' => $form->createView(), 'businessProperties' => $businessProperties)))); }
/** * Create a sitemap priority type. * * @return \Symfony\Component\Form\Form The form **/ protected function createSitemapPriorityType(BasePage $page) { $form = $this->createForm('victoire_sitemap_priority_pageseo_type', $page->getSeo(), ['action' => $this->generateUrl('victoire_sitemap_changePriority', ['id' => $page->getId()]), 'method' => 'PUT', 'attr' => ['class' => 'sitemapPriorityForm form-inline', 'data-pageId' => $page->getId(), 'id' => 'sitemap-priority-type-' . $page->getId(), 'style' => 'display: inline;']]); return $form; }