/**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getChangeFrequency()) {
         return;
     }
     $urlInformation->setChangeFrequency($this->defaultChangeFrequency);
 }
 /**
  * Updates UrlInformation with new values if they are not already set.
  *
  * @param UrlInformation $urlInformation The value object to update.
  * @param object         $object         The sitemap element to get values from.
  * @param string         $sitemap        Name of the sitemap being built.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($object instanceof SitemapPropertiesReadInterface) {
         if (!$urlInformation->getChangeFrequency() && ($period = $object->getUpdatePeriod())) {
             $urlInformation->setChangeFrequency($period);
         }
         if ($urlInformation->getPriority() === null) {
             $weight = $object->getPageWeight();
             if ($weight !== null) {
                 $urlInformation->setPriority($weight);
             }
         }
     }
 }
Exemplo n.º 3
0
 public function testValidChangeFrequency()
 {
     $this->model->setChangeFrequency('never');
     $this->assertEquals('never', $this->model->getChangeFrequency());
 }
 /**
  * Transforms a single sitemap document into url information.
  *
  * A sitemap document is a document, which should be exposed on a sitemap.
  *
  * @param object $document
  *
  * @return UrlInformation
  */
 protected function computeUrlInformationFromSitemapDocument($document)
 {
     $urlInformation = new UrlInformation();
     $urlInformation->setLocation($this->router->generate($document, array(), true));
     $urlInformation->setChangeFrequency($this->defaultChanFrequency);
     if ($this->alternateLocaleProvider) {
         $collection = $this->alternateLocaleProvider->createForContent($document);
         $urlInformation->setAlternateLocales($collection->toArray());
     }
     $seoMetadata = $this->seoPresentation->getSeoMetadata($document);
     if (null !== $seoMetadata->getTitle()) {
         $urlInformation->setLabel($seoMetadata->getTitle());
         return $urlInformation;
     }
     return $urlInformation;
 }