Esempio n. 1
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequest()->attributes->has($this->requestKey)) {
         $content = $event->getRequest()->attributes->get($this->requestKey);
         $this->seoPresentation->updateSeoPage($content);
         // look if the strategy is redirectResponse and if there is a route to redirectResponse to
         $response = $this->seoPresentation->getRedirectResponse();
         if (false !== $response && $this->canBeRedirected($event->getRequest(), $response)) {
             $event->setResponse($response);
         }
         if (null !== $this->alternateLocaleProvider) {
             $this->seoPresentation->updateAlternateLocales($this->alternateLocaleProvider->createForContent($content));
         }
     }
 }
Esempio n. 2
0
 /**
  * Example usage: {% set cmfMainContent = cmf_find_current_published_content(['acme_message/inbox', 'acme_message']) %}
  * This example will try to find a content at /cms/content/acme_message/inbox, update the SEO Meta data and stores
  * the content document in the cmfMainContent variable. Using 
  *     {% block html_title %}{{ sonata_seo_title() }}{% endblock html_title %}
  *     {% block html_metadatas %}{{ sonata_seo_metadatas() }}{% endblock html_metadatas %}
  * in a parent will apply the seo meta data from the page.
  * */
 public function findCurrentPublishedCMFContent($optionalContentNames)
 {
     if (!is_array($optionalContentNames)) {
         $optionalContentNames = array($optionalContentNames);
     }
     $match = null;
     foreach ($optionalContentNames as $contentName) {
         $contentPath = substr($contentName, 0, 1) !== '/' ? $this->defaultContentPath . "/" . $contentName : $contentName;
         $content = $this->helper->find($contentPath);
         if ($content && $this->helper->isPublished($content)) {
             $this->seoPresentation->updateSeoPage($content);
             $match = $content;
             break;
         }
     }
     return $match;
 }
Esempio n. 3
0
 /**
  * @see SeoPresentationInterface
  */
 public function updateMetadata($content)
 {
     $this->seoPresentation->updateSeoPage($content);
 }