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; }