/**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getChangeFrequency()) {
         return;
     }
     $urlInformation->setChangeFrequency($this->defaultChangeFrequency);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getLocation()) {
         return;
     }
     $urlInformation->setLocation($this->urlGenerator->generate($object, array(), true));
 }
 public function testGuessNoOverwrite()
 {
     $urlInformation = new UrlInformation();
     $urlInformation->setLastModification(new \DateTime('2016-06-06', new \DateTimeZone('Europe/Berlin')));
     $this->guesser->guessValues($urlInformation, $this->data, 'default');
     $this->assertEquals('2016-06-06T00:00:00+02:00', $urlInformation->getLastModification());
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getLocation()) {
         return;
     }
     $urlInformation->setLocation($this->urlGenerator->generate($object, array(), UrlGeneratorInterface::ABSOLUTE_URL));
 }
 /**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getAlternateLocales()) {
         return;
     }
     $collection = $this->alternateLocaleProvider->createForContent($object);
     $urlInformation->setAlternateLocales($collection->toArray());
 }
 /**
  * {@inheritdoc}.
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if ($urlInformation->getLabel()) {
         return;
     }
     $seoMetadata = $this->seoPresentation->getSeoMetadata($object);
     if ($seoMetadata->getTitle()) {
         $urlInformation->setLabel($seoMetadata->getTitle());
     }
 }
 /**
  * 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 ($urlInformation->getLastModification()) {
         return;
     }
     if ($object instanceof SeoContent) {
         /* @var $object SeoContent */
         $urlInformation->setLastModification(max($object->getUpdatedAt(), $this->recursiveBlockUpdateDate($object->getAdditionalInfoBlock())));
     }
 }
Exemplo n.º 8
0
 private function createUrlInformation()
 {
     $resultList = array();
     $urlInformation = new UrlInformation();
     $urlInformation->setLocation('http://www.test-alternate-locale.de')->setChangeFrequency('never')->setLabel('Test alternate locale')->setPriority(0.85)->setLastModification(new \DateTime('2014-11-07', new \DateTimeZone('Europe/Berlin')));
     $alternateLocale = new AlternateLocale('http://www.test-alternate-locale.com', 'en');
     $urlInformation->addAlternateLocale($alternateLocale);
     $resultList[] = $urlInformation;
     $urlInformation = new UrlInformation();
     $urlInformation->setLocation('http://www.test-domain.de')->setChangeFrequency('always')->setLabel('Test label')->setPriority(0.85)->setLastModification(new \DateTime('2014-11-06', new \DateTimeZone('Europe/Berlin')));
     $resultList[] = $urlInformation;
     return $resultList;
 }
 private function createRoutes()
 {
     $urls = array();
     $simpleUrl = new UrlInformation();
     $simpleUrl->setLocation('http://www.test-domain.de')->setChangeFrequency('always')->setLabel('Test label')->setPriority(0.85)->setLastModification(new \DateTime('2014-11-06', new \DateTimeZone('Europe/Berlin')));
     $urlWithAlternateLocale = new UrlInformation();
     $urlWithAlternateLocale->setLocation('http://www.test-alternate-locale.de')->setChangeFrequency('never')->setLabel('Test alternate locale')->setPriority(0.85)->setLastModification(new \DateTime('2014-11-07', new \DateTimeZone('Europe/Berlin')));
     $alternateLocale = new AlternateLocale('http://www.test-alternate-locale.com', 'en');
     $urlWithAlternateLocale->addAlternateLocale($alternateLocale);
     $urls[] = $urlWithAlternateLocale;
     $urls[] = $simpleUrl;
     $this->provider->expects($this->any())->method('getUrlInformation')->will($this->returnValue($urls));
 }
Exemplo n.º 10
0
 /**
  * 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.º 11
0
 /**
  * {@inheritdoc}
  */
 public function guessValues(UrlInformation $urlInformation, $object, $sitemap)
 {
     if (null !== $urlInformation->getDepth()) {
         return;
     }
     $manager = $this->managerRegistry->getManagerForClass(ClassUtils::getRealClass(get_class($object)));
     if (!$manager instanceof DocumentManager) {
         return;
     }
     $node = $manager->getNodeForDocument($object);
     if (null === $node) {
         return;
     }
     $urlInformation->setDepth($node->getDepth() - $this->offset);
 }
 /**
  * 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 ($urlInformation->getLastModification()) {
         return;
     }
     if ($object instanceof OnePageContent) {
         /* @var $object OnePageContent */
         $updated = $object->getUpdatedAt();
         foreach ($object->getChildren(true) as $section) {
             /* @var $section OnePageSection */
             $updated = max($updated, $this->sectionUpdateDate($section));
         }
         $urlInformation->setLastModification($updated);
     } elseif ($object instanceof OnePageSection) {
         /* @var $object OnePageSection */
         $urlInformation->setLastModification($this->sectionUpdateDate($object));
     }
 }
Exemplo n.º 13
0
 /**
  * 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 (null !== $urlInformation->getLastModification()) {
         return;
     }
     $className = ClassUtils::getRealClass(get_class($object));
     $manager = $this->managerRegistry->getManagerForClass($className);
     if (!$manager instanceof DocumentManager) {
         return;
     }
     /** @var ClassMetadata $metadata */
     $metadata = $manager->getClassMetadata($className);
     $mixins = $metadata->getMixins();
     if (!in_array('mix:lastModified', $mixins)) {
         return;
     }
     $fieldName = $this->getFieldName($metadata);
     if (null === $fieldName) {
         return;
     }
     $urlInformation->setLastModification($metadata->getFieldValue($object, $fieldName));
 }
Exemplo n.º 14
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;
 }