/** * @param DOMDocument $styleSheet * @return Transpiler */ private function createTranspiler(DOMDocument $styleSheet) { $phpFunctions = $this->phpFunctions; if ($phpFunctions === null) { parent::registerPHPFunctions(); } else { $phpFunctions[] = PhpCallback::class . '::call'; $phpFunctions[] = PhpCallback::class . '::callStatic'; $phpFunctions[] = PhpCallback::class . '::callContext'; parent::registerPHPFunctions($phpFunctions); } $transformers = new TransformerCollection(); $functions = new FunctionMap(); $xpathCompiler = new Xpath\Compiler($functions); $context = new TransformationContext($styleSheet, $transformers, $functions, $phpFunctions); $namespaces = $this->getNamespaces($xpathCompiler); foreach ($namespaces as $namespace) { $namespace->register($transformers, $functions); } try { return new Transpiler($context, $this->config->getCacheAdapter()); } catch (CacheDisabledException $e) { return new Transpiler($context); } }
/** * @param Transpiler $transpiler * @return array */ private function createStreamOptions(Transpiler $transpiler) { $contextOptions = ['gxsl' => ['transpiler' => $transpiler]]; try { $contextOptions['gxsl']['cache'] = $this->config->getCacheAdapter(); } catch (CacheDisabledException $e) { // caching adapter is not required for the processor to run } return $contextOptions; }