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()); }
/** * 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)); } }
/** * 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()))); } }
/** * 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)); }