Skip to content

Commit

Permalink
Fix EZP-23865: Fix legacy kernel manual reset in core console applica…
Browse files Browse the repository at this point in the history
  • Loading branch information
lolautruche committed Jan 9, 2015
1 parent 1058c21 commit e0148e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
7 changes: 0 additions & 7 deletions eZ/Bundle/EzPublishCoreBundle/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ protected function registerCommands()
$this->siteAccessName = $this->siteAccessName ?: $container->getParameter( 'ezpublish.siteaccess.default' );
$siteAccess = new SiteAccess( $this->siteAccessName, 'cli' );
$container->set( 'ezpublish.siteaccess', $siteAccess );

// Replacing legacy kernel handler web by the CLI one
// @todo: this should be somewhat done in the legacy bundle
$legacyHandlerCLI = $container->get( 'ezpublish_legacy.kernel_handler.cli' );
$container->set( 'ezpublish_legacy.kernel.lazy', null );
$container->set( 'ezpublish_legacy.kernel_handler', $legacyHandlerCLI );
$container->set( 'ezpublish_legacy.kernel_handler.web', $legacyHandlerCLI );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
use eZ\Publish\Core\MVC\Legacy\LegacyEvents;
use eZ\Publish\Core\MVC\Legacy\Event\PreResetLegacyKernelEvent;
use eZINI;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Resets eZINI when the Legacy Kernel is reset.
*/
class LegacyKernelListener implements EventSubscriberInterface
class LegacyKernelListener extends ContainerAware implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return array(
LegacyEvents::PRE_RESET_LEGACY_KERNEL => 'onKernelReset'
);
return [
LegacyEvents::PRE_RESET_LEGACY_KERNEL => 'onKernelReset',
ConsoleEvents::COMMAND => 'onConsoleCommand'
];
}

public function onKernelReset( PreResetLegacyKernelEvent $event )
Expand All @@ -36,4 +40,12 @@ function() {
false
);
}

public function onConsoleCommand( ConsoleCommandEvent $event )
{
$legacyHandlerCLI = $this->container->get( 'ezpublish_legacy.kernel_handler.cli' );
$this->container->set( 'ezpublish_legacy.kernel.lazy', null );
$this->container->set( 'ezpublish_legacy.kernel_handler', $legacyHandlerCLI );
$this->container->set( 'ezpublish_legacy.kernel_handler.web', $legacyHandlerCLI );
}
}
2 changes: 2 additions & 0 deletions eZ/Bundle/EzPublishLegacyBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ services:

ezpublish_legacy.legacy_kernel_listener:
class: %ezpublish_legacy.legacy_kernel_listener.class%
calls:
- [setContainer, [@service_container]]
tags:
- { name: kernel.event_subscriber }

Expand Down

0 comments on commit e0148e5

Please sign in to comment.