Skip to content

Commit

Permalink
EZP-22152: Don't retrieve legacy templates list if legacy kernel ain'…
Browse files Browse the repository at this point in the history
…t booted
  • Loading branch information
lolautruche committed Jan 29, 2014
1 parent c99d7f5 commit ca46bd3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
13 changes: 10 additions & 3 deletions eZ/Bundle/EzPublishDebugBundle/Collector/TemplateDebugInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace eZ\Bundle\EzPublishDebugBundle\Collector;

use Symfony\Component\DependencyInjection\ContainerInterface;
use eZ\Publish\Core\MVC\Legacy\Kernel as LegacyKernel;
use eZTemplate;

/**
Expand Down Expand Up @@ -64,19 +64,26 @@ public static function getTemplatesList()
/**
* Returns array of loaded legacy templates
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @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;
}

$templateStats = $legacyKernel()->runCallback(
function ()
{
return eZTemplate::templatesUsageStatistics();
}
);

$templateList = array( 'compact' => array(), 'full' => array() );
foreach ( $templateStats as $tplInfo )
{
$requestedTpl = $tplInfo["requested-template-name"];
Expand Down
10 changes: 10 additions & 0 deletions eZ/Publish/Core/MVC/Legacy/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ public function __construct( ezpKernelHandler $kernelHandler, $legacyRootDir, $w
$this->setUseExceptions( true );
}

/**
* Checks if LegacyKernel has already been instantiated.
*
* @return bool
*/
public static function hasInstance()
{
return static::$instance !== null;
}

/**
* Changes the current working directory to the legacy root dir.
* Calling this method is mandatory to use legacy kernel since a lot of resources in eZ Publish 4.x relatively defined.
Expand Down

0 comments on commit ca46bd3

Please sign in to comment.