コード例 #1
0
ファイル: Template.php プロジェクト: edde-framework/edde
 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();
     });
 }
コード例 #2
0
 public function build()
 {
     if ($this->built === true) {
         return $this;
     }
     $this->built = true;
     if (empty($this->pathList)) {
         return $this;
     }
     $cacheId = sha1(implode('', array_merge(array_values($this->pathList), array_values($this->extensionList))));
     if (($this->reflectionFileList = $this->cache->load($cacheId)) !== null) {
         return $this;
     }
     $this->scanner->reindex();
     $selectQuery = $this->scanner->createQuery();
     $selectQuery->setPathList($this->pathList);
     $selectQuery->setExtensionList($this->extensionList);
     foreach ($this->scanner->query($selectQuery) as $scannerItem) {
         $source = SourceLexer::build($file = $scannerItem->getFile());
         foreach ($source->classList as $class) {
             $this->reflectionFileList[$class->name] = $file;
         }
         foreach ($source->interfaceList as $interface) {
             $this->reflectionFileList[$interface->name] = $file;
         }
         foreach ($source->traitList as $trait) {
             $this->reflectionFileList[$trait->name] = $file;
         }
         foreach ($source->namespaceList as $namespace) {
             foreach ($namespace->classList as $class) {
                 $this->reflectionFileList[$namespace->name . '\\' . $class->name] = $file;
             }
             foreach ($namespace->interfaceList as $interface) {
                 $this->reflectionFileList[$namespace->name . '\\' . $interface->name] = $file;
             }
             foreach ($namespace->traitList as $trait) {
                 $this->reflectionFileList[$namespace->name . '\\' . $trait->name] = $file;
             }
         }
     }
     $this->cache->save($cacheId, $this->reflectionFileList);
     return $this;
 }