Beispiel #1
0
 public function render()
 {
     $template = new TempFile($cacheId = sha1($this->resource->getUri()));
     //			if (!$template->exists()) {
     $template->openForWrite();
     $template->write($this->cache->load($cacheId, function () use($cacheId) {
         $header = sprintf("<?php\n\t/**\n\t * stamp: %s\n\t *\n\t * layout:\n\t * %s", DateTimeUtils::from('now')->format('Y-m-d H:i:s'), $this->resource->getUri());
         if (!empty($this->resourceList)) {
             $header .= "\n\n\t * used templates:";
         }
         foreach ($this->resourceList as $resource) {
             $header .= "\n\t * - " . $resource->getUri() . "\n";
         }
         $header .= "\t */\n?>\n";
         return $this->cache->save($cacheId, $header . $this->compile());
     }));
     $template->close();
     //			}
     call_user_func(function () use($template) {
         require_once $template->getFullFileName();
     });
 }
 /**
  * @return string
  */
 public function getUri()
 {
     return $this->resource->getUri();
 }
Beispiel #3
0
 public function addResource(IResource $resource, $required = true)
 {
     $this->resourceList[$resource->getUri()] = [$resource, $required];
     return $this;
 }