예제 #1
0
 function loadFromCache(CachingFileCompiler $cache, $sourceFile)
 {
     global $usrlz_ctx, $usrlz_inj;
     // Preserve the current context.
     $prev_ctx = $usrlz_ctx;
     $usrlz_ctx = $this->context->makeSubcontext();
     $usrlz_inj = $this->injector;
     $compiled = $cache->get($sourceFile, function ($source) use($sourceFile) {
         $root = $this->compile($source);
         if ($root instanceof CompositeComponent) {
             $root->templateUrl = $sourceFile;
         }
         return $root;
     });
     // Restore the current context.
     $usrlz_ctx = $prev_ctx;
     if ($this->rootClass) {
         /** @var CompositeComponent $root */
         $root = $this->injector->make($this->rootClass);
         $root->setContext($this->context->makeSubcontext());
         $root->setShadowDOM($compiled);
         return $root;
     }
     return $compiled;
 }
예제 #2
0
 /**
  * Configures a DocumentContext from Matisse's configuration settings.
  *
  * @param DocumentContext $ctx
  */
 function initContext(DocumentContext $ctx)
 {
     $ctx->condenseLiterals = !$this->devEnv;
     $ctx->devEnv = $this->devEnv;
     $ctx->controllers = $this->controllers;
     $ctx->controllerNamespaces = $this->controllerNamespaces;
     $ctx->registerTags($this->tags);
     $ctx->setFilterHandler(new FilterHandler(new DefaultFilters()));
     $ctx->getDataBinder()->setContext($ctx);
 }