Пример #1
0
 /**
  * Generate a seo for the page using the current entity
  *
  * @param Page   $page
  * @param Entity $entity
  */
 public function updateSeoByEntity(BasePage $page, $entity)
 {
     //if no entity is provided
     if ($entity === null) {
         //we look for the entity of the page
         if ($page->getBusinessEntity() !== null) {
             $entity = $page->getBusinessEntity();
         }
     }
     //only if we have an entity instance
     if ($entity !== null) {
         //the page seo
         $pageSeo = $page->getSeo();
         //the page seo might not exist yet
         if ($pageSeo !== null) {
             $businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
             if ($businessEntity !== null) {
                 $businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
                 //parse the business properties
                 foreach ($businessProperties as $businessProperty) {
                     //parse of seo attributes
                     foreach ($this->pageSeoAttributes as $seoAttribute) {
                         $string = $this->getEntityAttributeValue($pageSeo, $seoAttribute);
                         $updatedString = $this->parameterConverter->setBusinessPropertyInstance($string, $businessProperty, $entity);
                         $this->setEntityAttributeValue($pageSeo, $seoAttribute, $updatedString);
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * Generate a seo for the page using the current entity.
  *
  * @param Page   $page
  * @param Entity $entity
  */
 public function updateSeoByEntity(BasePage $page, $entity)
 {
     //if no entity is provided
     if ($entity === null) {
         //we look for the entity of the page
         if ($page->getBusinessEntity() !== null) {
             $entity = $page->getBusinessEntity();
         }
     }
     //only if we have an entity instance
     if ($entity !== null) {
         //the page seo
         $pageSeo = $page->getSeo();
         //the page seo might not exist yet
         if ($pageSeo !== null) {
             $businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
             if ($businessEntity !== null) {
                 $businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
                 //parse the business properties
                 foreach ($businessProperties as $businessProperty) {
                     //parse of seo attributes
                     foreach ($this->pageSeoAttributes as $seoAttribute) {
                         $value = $this->getEntityAttributeValue($pageSeo, $seoAttribute);
                         // we only update value if its a string and (if its a VBP or its a BP where value is not defined)
                         if (is_string($value) && ($page instanceof VirtualBusinessPage || $page instanceof BusinessPage && $value == null)) {
                             $value = $this->parameterConverter->setBusinessPropertyInstance($value, $businessProperty, $entity);
                         }
                         $this->setEntityAttributeValue($pageSeo, $seoAttribute, $value);
                     }
                 }
             }
         }
     }
 }
Пример #3
0
 /**
  * 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))));
 }
Пример #4
0
 /**
  * Get the list of urls of the children.
  *
  * @param BasePage $page
  *
  * @return aray of strings The list of urls
  */
 protected function getChildrenUrls(BasePage $page)
 {
     $urls = [];
     $children = $page->getInstances();
     //parse the children
     foreach ($children as $child) {
         $url = $child->getUrl();
         $urls[] = $url;
         unset($url);
     }
     return $urls;
 }
Пример #5
0
 /**
  * add page.
  *
  * @param BasePage $page
  *
  * @return Template
  **/
 public function addPage(BasePage $page)
 {
     $page->setTemplate($this);
     $this->pages[] = $page;
     return $this;
 }
Пример #6
0
 /**
  * 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;
 }
Пример #7
0
 /**
  * @param Page $page The page to delete
  *
  * @return Response
  */
 public function deleteAction(BasePage $page)
 {
     $response = null;
     try {
         //it should not be allowed to try to delete an undeletable page
         if ($page->isUndeletable()) {
             $message = $this->get('translator')->trans('page.undeletable', [], 'victoire');
             throw new \Exception($message);
         }
         //the entity manager
         $entityManager = $this->get('doctrine.orm.entity_manager');
         //remove the page
         $entityManager->remove($page);
         //flush the modifications
         $entityManager->flush();
         //redirect to the homepage
         $homepageUrl = $this->generateUrl('victoire_core_homepage_show');
         $response = ['success' => true, 'url' => $homepageUrl];
     } catch (\Exception $ex) {
         $response = ['success' => false, 'message' => $ex->getMessage()];
     }
     return $response;
 }
Пример #8
0
 /**
  * Construct.
  **/
 public function __construct()
 {
     parent::__construct();
 }