merged branch Tobion/console-dispatcher (PR #8158)
This PR was merged into the 2.3 branch. Discussion ---------- [FrameworkBundle] set the dispatcher in the console application BC break: no test pass: yes Otherwise events are not dispatched in symfony frameworkbundle. The first commit fixes a related typehint in the console. Commits -------e93fc7a
[FrameworkBundle] set the dispatcher in the console application176a3d4
[Console] fix typehint for Application::setDispatcher
This commit is contained in:
commit
b5c9bb8e03
@ -67,6 +67,8 @@ class Application extends BaseApplication
|
|||||||
{
|
{
|
||||||
$this->registerCommands();
|
$this->registerCommands();
|
||||||
|
|
||||||
|
$this->setDispatcher($this->kernel->getContainer()->get('event_dispatcher'));
|
||||||
|
|
||||||
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
|
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
|
||||||
$shell = new Shell($this);
|
$shell = new Shell($this);
|
||||||
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
|
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
|
||||||
|
@ -20,7 +20,7 @@ class ApplicationTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testBundleInterfaceImplementation()
|
public function testBundleInterfaceImplementation()
|
||||||
{
|
{
|
||||||
$bundle = $this->getMock("Symfony\Component\HttpKernel\Bundle\BundleInterface");
|
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
|
||||||
|
|
||||||
$kernel = $this->getKernel(array($bundle));
|
$kernel = $this->getKernel(array($bundle));
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
public function testBundleCommandsAreRegistered()
|
public function testBundleCommandsAreRegistered()
|
||||||
{
|
{
|
||||||
$bundle = $this->getMock("Symfony\Component\HttpKernel\Bundle\Bundle");
|
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
|
||||||
$bundle->expects($this->once())->method('registerCommands');
|
$bundle->expects($this->once())->method('registerCommands');
|
||||||
|
|
||||||
$kernel = $this->getKernel(array($bundle));
|
$kernel = $this->getKernel(array($bundle));
|
||||||
@ -41,12 +41,31 @@ class ApplicationTest extends TestCase
|
|||||||
|
|
||||||
private function getKernel(array $bundles)
|
private function getKernel(array $bundles)
|
||||||
{
|
{
|
||||||
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
|
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||||
|
$dispatcher
|
||||||
|
->expects($this->atLeastOnce())
|
||||||
|
->method('dispatch')
|
||||||
|
;
|
||||||
|
|
||||||
|
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||||
|
$container
|
||||||
|
->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with($this->equalTo('event_dispatcher'))
|
||||||
|
->will($this->returnValue($dispatcher))
|
||||||
|
;
|
||||||
|
|
||||||
|
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
|
||||||
$kernel
|
$kernel
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getBundles')
|
->method('getBundles')
|
||||||
->will($this->returnValue($bundles))
|
->will($this->returnValue($bundles))
|
||||||
;
|
;
|
||||||
|
$kernel
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getContainer')
|
||||||
|
->will($this->returnValue($container))
|
||||||
|
;
|
||||||
|
|
||||||
return $kernel;
|
return $kernel;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ use Symfony\Component\Console\Helper\TableHelper;
|
|||||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||||
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
||||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Application is the container for a collection of commands.
|
* An Application is the container for a collection of commands.
|
||||||
@ -88,7 +88,7 @@ class Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDispatcher(EventDispatcher $dispatcher)
|
public function setDispatcher(EventDispatcherInterface $dispatcher)
|
||||||
{
|
{
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user