/** * Returns array of loaded legacy templates * * @param \Closure $legacyKernel * * @return array */ public static function getLegacyTemplatesList(\Closure $legacyKernel) { $templateList = array('compact' => array(), 'full' => array()); // Only retrieve legacy templates list if the kernel has been booted at least once. if (!LegacyKernel::hasInstance()) { return $templateList; } try { $templateStats = $legacyKernel()->runCallback(function () { return eZTemplate::templatesUsageStatistics(); }, false, false); } catch (RuntimeException $e) { // Ignore the exception thrown by legacy kernel as this would break debug toolbar (and thus debug info display). // Furthermore, some legacy kernel handlers don't support runCallback (e.g. ezpKernelTreeMenu) $templateStats = array(); } foreach ($templateStats as $tplInfo) { $requestedTpl = $tplInfo["requested-template-name"]; $actualTpl = $tplInfo["actual-template-name"]; $fullPath = $tplInfo["template-filename"]; $templateList["full"][$actualTpl] = array("loaded" => $requestedTpl, "fullPath" => $fullPath); if (!isset($templateList["compact"][$actualTpl])) { $templateList["compact"][$actualTpl] = 1; } else { $templateList["compact"][$actualTpl]++; } } return $templateList; }
/** * Returns the value of the legacy parameter $parameterName in $groupName. * If $file and $siteaccess are null, the global value is fetched with the * legacy resolver. * * @param string $groupName * @param string $parameterName * @param string|null $file * @param string|null $siteaccess * * @return array */ public function getParameter($groupName, $parameterName, $file = null, $siteaccess = null) { if ($file === null && $siteaccess === null) { // in this case we want the "global" value, no need to use the // legacy kernel, the legacy resolver is enough return $this->legacyResolver->getParameter("{$groupName}.{$parameterName}"); } return $this->legacyKernel->runCallback(function () use($file, $groupName, $parameterName, $siteaccess) { // @todo: do reset injected settings everytime // and make sure to restore the previous injected settings eZINI::injectSettings(array()); return eZSiteAccess::getIni($siteaccess, $file)->variable($groupName, $parameterName); }, false, false); }
/** * Returns array of loaded legacy templates * * @param \Closure $legacyKernel * * @return array */ public static function getLegacyTemplatesList(\Closure $legacyKernel) { $templateList = array('compact' => array(), 'full' => array()); // Only retrieve legacy templates list if the kernel has been booted at least once. if (!LegacyKernel::hasInstance()) { return $templateList; } $formTokenWasEnabled = false; try { // Deactivate ezxFormToken to avoid double checks on it. // Checking on ezxFormToken existence since might not be loadable if eZ is not yet installed // (ezp_extension.php not yet generated in legacy). if (class_exists('ezxFormToken') && ($formTokenWasEnabled = ezxFormToken::isEnabled())) { ezxFormToken::setIsEnabled(false); } $templateStats = $legacyKernel()->runCallback(function () { return eZTemplate::templatesUsageStatistics(); }); } catch (RuntimeException $e) { // Ignore the exception thrown by legacy kernel as this would break debug toolbar (and thus debug info display). // Furthermore, some legacy kernel handlers don't support runCallback (e.g. ezpKernelTreeMenu) $templateStats = array(); if ($formTokenWasEnabled) { ezxFormToken::setIsEnabled(true); } } foreach ($templateStats as $tplInfo) { $requestedTpl = $tplInfo["requested-template-name"]; $actualTpl = $tplInfo["actual-template-name"]; $fullPath = $tplInfo["template-filename"]; $templateList["full"][$actualTpl] = array("loaded" => $requestedTpl, "fullPath" => $fullPath); if (!isset($templateList["compact"][$actualTpl])) { $templateList["compact"][$actualTpl] = 1; } else { $templateList["compact"][$actualTpl]++; } } // Re-activate ezxFormToken if it was before, as we might be inside an inline sub-request. // See https://jira.ez.no/browse/EZP-22643 if ($formTokenWasEnabled) { ezxFormToken::setIsEnabled(true); } return $templateList; }
/** * Resets the legacy kernel instances from the container * * @return void */ public function resetKernel() { /** @var \Closure $kernelClosure */ $kernelClosure = $this->container->get('ezpublish_legacy.kernel'); $this->eventDispatcher->dispatch(LegacyEvents::PRE_RESET_LEGACY_KERNEL, new PreResetLegacyKernelEvent($kernelClosure())); LegacyKernel::resetInstance(); $this->webHandler = null; $this->cliHandler = null; $this->container->set('ezpublish_legacy.kernel.lazy', null); $this->container->set('ezpublish_legacy.kernel_handler.web', null); $this->container->set('ezpublish_legacy.kernel_handler.cli', null); }