コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function updateSeoPage($content)
 {
     $seoMetadata = $this->getSeoMetadata($content);
     $translationDomain = $this->configValues->getTranslationDomain();
     if ($extraProperties = $seoMetadata->getExtraProperties()) {
         foreach ($extraProperties as $key => $value) {
             $this->sonataPage->addMeta('property', $key, $value);
         }
     }
     if ($extraNames = $seoMetadata->getExtraNames()) {
         foreach ($extraNames as $key => $value) {
             $this->sonataPage->addMeta('name', $key, $value);
         }
     }
     if ($extraHttp = $seoMetadata->getExtraHttp()) {
         foreach ($extraHttp as $key => $value) {
             $this->sonataPage->addMeta('http-equiv', $key, $value);
         }
     }
     if ($seoMetadata->getTitle()) {
         $pageTitle = null !== $this->configValues->getTitle() ? $this->translator->trans($this->configValues->getTitle(), array('%content_title%' => $seoMetadata->getTitle()), $translationDomain) : $seoMetadata->getTitle();
         $this->sonataPage->setTitle($pageTitle);
     }
     if ($seoMetadata->getMetaDescription()) {
         $pageDescription = null !== $this->configValues->getDescription() ? $this->translator->trans($this->configValues->getDescription(), array('%content_description%' => $seoMetadata->getMetaDescription()), $translationDomain) : $seoMetadata->getMetaDescription();
         $this->sonataPage->addMeta('name', 'description', $pageDescription);
     }
     if ($seoMetadata->getMetaKeywords()) {
         $this->sonataPage->addMeta('name', 'keywords', $this->createKeywords($seoMetadata->getMetaKeywords()));
     }
     $url = $seoMetadata->getOriginalUrl();
     if ($url) {
         switch ($this->configValues->getOriginalUrlBehaviour()) {
             case self::ORIGINAL_URL_CANONICAL:
                 $this->sonataPage->setLinkCanonical($url);
                 break;
             case self::ORIGINAL_URL_REDIRECT:
                 $this->setRedirectResponse(new RedirectResponse($url));
                 break;
         }
     }
     if ($this->locale) {
         $this->sonataPage->addMeta('http-equiv', 'language', $this->locale);
     }
 }
コード例 #2
0
 /**
  * @expectedException \Symfony\Cmf\Bundle\SeoBundle\Exception\ExtractorStrategyException
  */
 public function testInvalidStrategy()
 {
     $configValues = new ConfigValues();
     $configValues->setOriginalUrlBehaviour('nonexistent');
 }