Skip to content

Commit

Permalink
EZP-22152: Fixed debug of legacy templates list when not in pure web …
Browse files Browse the repository at this point in the history
…context
  • Loading branch information
lolautruche committed Jan 30, 2014
1 parent ca46bd3 commit 2b27571
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
21 changes: 15 additions & 6 deletions eZ/Bundle/EzPublishDebugBundle/Collector/TemplateDebugInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use eZ\Publish\Core\MVC\Legacy\Kernel as LegacyKernel;
use eZTemplate;
use RuntimeException;

/**
* Class TemplateDebugInfo
Expand Down Expand Up @@ -77,12 +78,20 @@ public static function getLegacyTemplatesList( \Closure $legacyKernel )
return $templateList;
}

$templateStats = $legacyKernel()->runCallback(
function ()
{
return eZTemplate::templatesUsageStatistics();
}
);
try
{
$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)
}

foreach ( $templateStats as $tplInfo )
{
Expand Down
21 changes: 11 additions & 10 deletions eZ/Publish/Core/MVC/Legacy/Kernel/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,20 @@ public function buildLegacyKernel( $legacyKernelHandler )
$eventDispatcher = $this->eventDispatcher;
return function () use ( $legacyKernelHandler, $legacyRootDir, $webrootDir, $eventDispatcher )
{
static $legacyKernel;
if ( !$legacyKernel instanceof LegacyKernel )
if ( LegacyKernel::hasInstance() )
{
if ( $legacyKernelHandler instanceof \Closure )
$legacyKernelHandler = $legacyKernelHandler();
$legacyKernel = new LegacyKernel( $legacyKernelHandler, $legacyRootDir, $webrootDir );

$eventDispatcher->dispatch(
LegacyEvents::POST_BUILD_LEGACY_KERNEL,
new PostBuildKernelEvent( $legacyKernel, $legacyKernelHandler )
);
return LegacyKernel::instance();
}

if ( $legacyKernelHandler instanceof \Closure )
$legacyKernelHandler = $legacyKernelHandler();
$legacyKernel = new LegacyKernel( $legacyKernelHandler, $legacyRootDir, $webrootDir );

$eventDispatcher->dispatch(
LegacyEvents::POST_BUILD_LEGACY_KERNEL,
new PostBuildKernelEvent( $legacyKernel, $legacyKernelHandler )
);

return $legacyKernel;
};
}
Expand Down

0 comments on commit 2b27571

Please sign in to comment.