コード例 #1
0
ファイル: TemplateApplier.php プロジェクト: maslosoft/staple
 public function decorate(RendererAwareInterface $owner, &$content, $data)
 {
     $template = empty($data['template']) ? $this->template : $data['template'];
     $view = new MiniView($this, sprintf('%s/%s', $owner->getRootPath(), $owner->getLayoutPath()));
     $view->setViewsPath('');
     $data['content'] = $content;
     $content = $view->render($template, ['data' => (object) $data, 'view' => $view], true);
 }
コード例 #2
0
 public function getData(RendererAwareInterface $owner, $filename, $view)
 {
     $data = [];
     $path = sprintf('%s/%s/%s', $owner->getRootPath(), $owner->getContentPath(), $this->filename);
     if (file_exists($path)) {
         $data = (array) json_decode(file_get_contents($path));
     }
     return $data;
 }
コード例 #3
0
 public function getData(RendererAwareInterface $owner, $filename, $view)
 {
     $data = [];
     $rootPath = realpath($owner->getRootPath());
     $path = dirname($filename);
     $parts = explode('/', $path);
     foreach ($parts as $part) {
         $filePath = sprintf('%s/%s', $path, $this->filename);
         if (file_exists($filePath)) {
             $data = array_merge((array) json_decode(file_get_contents($filePath), false), $data);
         }
         $path = realpath($path . '/../');
         if ($path === $rootPath) {
             break;
         }
     }
     return $data;
 }
コード例 #4
0
ファイル: PostProcessor.php プロジェクト: maslosoft/staple
 public function decorate(RendererAwareInterface $owner, &$content, $data)
 {
     foreach ($owner->getPostProcessors() as $postProcessor) {
         $postProcessor->decorate($owner, $content, $data);
     }
 }