/** * Build base format context * * @param mixed $context * * @return Configuration */ protected function buildBaseFormatContext($context) { $baseContext = new Configuration(array('site' => $this->siteConfiguration->export(), 'page' => $context, 'formatter' => $this->defaultFormatter, 'converters' => array())); if (isset($context['url'])) { if ('/' === $context['url']) { $relativeUrl = '.'; } else { $relativeUrl = rtrim(str_repeat('../', substr_count($context['url'], '/')), '/'); } $baseContext->set('relative_root_url', $relativeUrl); } foreach ($this->dataProviderManager->dataProviders() as $name) { if (isset($context['use']) and in_array($name, $context['use'])) { $baseContext->set('data.' . $name, $this->dataProviderManager->dataProvider($name)->provideData()); } } return $baseContext; }
/** * {@inheritdoc} */ public function duplicate($newSourceId, array $options = array()) { return new MemorySource($newSourceId, new Data($this->data->exportRaw()), isset($options['content']) ? $options['content'] : $this->content, isset($options['formattedContent']) ? $options['formattedContent'] : $this->formattedContent, isset($options['relativePathname']) ? $options['relativePathname'] : $this->relativePathname, isset($options['filename']) ? $options['filename'] : $this->filename, isset($options['file']) ? $options['file'] : $this->file, isset($options['isRaw']) ? $options['isRaw'] : $this->isRaw, isset($options['canBeFormatted']) ? $options['canBeFormatted'] : $this->canBeFormatted, isset($options['hasChanged']) ? $options['hasChanged'] : $this->hasChanged); }
/** * Formatter * * @return string */ public function formatter() { return $this->data->get('formatter'); }