public function testAllSources() { $source000 = $this->makeTestSource('TestSource:000'); $source001 = $this->makeTestSource('TestSource:001'); $source002 = $this->makeTestSource('TestSource:002'); $sourceSet = new SourceSet(array($source000, $source001, $source002)); $this->assertEquals(array('TestSource:000' => $source000, 'TestSource:001' => $source001, 'TestSource:002' => $source002), $sourceSet->allSources()); }
protected function setListItems(SourceSet $sourceSet) { foreach ($sourceSet->allSources() as $source) { if ($source->isGenerated() || !$source->canBeFormatted()) { continue; } $source->data()->set('list', $this->listitems); } }
/** * {@inheritdoc} */ public function refresh(SourceSet $sourceSet) { $sinceTimeLast = $this->sinceTime; $this->sinceTime = date('c'); // We regenerate the whole site if an excluded file changes. $excludedFilesHaveChanged = false; $files = $this->finderFactory->createFinder()->files()->ignoreVCS(true)->ignoreDotFiles(false)->date('>=' . $sinceTimeLast)->followLinks()->in($this->sourceDir); $sinceTimeLastSeconds = strtotime($sinceTimeLast); foreach ($files as $file) { if ($sinceTimeLastSeconds > $file->getMTime()) { // This is a hack because Finder is actually incapable // of resolution down to seconds. // // Sometimes this may result in the file looking like it // has been modified twice in a row when it has not. continue; } foreach ($this->ignores as $pattern) { if (!$this->matcher->isPattern($pattern)) { continue; } if ($this->matcher->match($pattern, $this->directorySeparatorNormalizer->normalize($file->getRelativePathname()))) { // Ignored files are completely ignored. continue 2; } } foreach ($this->excludes as $pattern) { if (!$this->matcher->isPattern($pattern)) { continue; } if ($this->matcher->match($pattern, $this->directorySeparatorNormalizer->normalize($file->getRelativePathname()))) { $excludedFilesHaveChanged = true; continue 2; } } $isRaw = false; foreach ($this->raws as $pattern) { if (!$this->matcher->isPattern($pattern)) { continue; } if ($this->matcher->match($pattern, $this->directorySeparatorNormalizer->normalize($file->getRelativePathname()))) { $isRaw = true; break; } } $source = new FileSource($this->analyzer, $this, $file, $isRaw, true); $sourceSet->mergeSource($source); } if ($excludedFilesHaveChanged) { // If any of the exluded files have changed we should // mark all of the sources as having changed. foreach ($sourceSet->allSources() as $source) { $source->setHasChanged(); } } }
/** * {@inheritdoc} */ public function refresh(SourceSet $sourceSet) { if (!is_dir($this->sourceDir)) { return; } $sinceTimeLast = $this->sinceTime; $this->sinceTime = date('c'); // We regenerate the whole site if any config file changes. $configFilesHaveChanged = false; $files = $this->finderFactory->createFinder()->files()->name('sculpin_site*.yml')->date('>=' . $sinceTimeLast)->in($this->sourceDir); $sinceTimeLastSeconds = strtotime($sinceTimeLast); foreach ($files as $file) { if ($sinceTimeLastSeconds > $file->getMTime()) { // This is a hack because Finder is actually incapable // of resolution down to seconds. // // Sometimes this may result in the file looking like it // has been modified twice in a row when it has not. continue; } $configFilesHaveChanged = true; break; } if ($configFilesHaveChanged) { $newConfig = $this->siteConfigurationFactory->create(); $this->siteConfiguration->import($newConfig); // If any of the config files have changed we should // mark all of the sources as having changed. foreach ($sourceSet->allSources() as $source) { $source->setHasChanged(); } } }
/** * All sources * * @return array */ public function allSources() { return $this->sourceSet->allSources(); }