From 366484c270c1cd6a85bd5b8f03629380d192a0c3 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 18 Apr 2016 22:21:12 -0400 Subject: [PATCH] Don't double bind dispatch filters. Binding dispatcher filters is done by the Dispatcher for people using the 'old' setup. Binding here add hidden global state and duplicates the bindings which is undesirable. --- src/Http/ActionDispatcher.php | 5 ---- tests/TestCase/Http/ActionDispatcherTest.php | 28 -------------------- 2 files changed, 33 deletions(-) diff --git a/src/Http/ActionDispatcher.php b/src/Http/ActionDispatcher.php index 778007e1077..7e738949c0d 100644 --- a/src/Http/ActionDispatcher.php +++ b/src/Http/ActionDispatcher.php @@ -61,11 +61,6 @@ public function __construct($factory = null, $eventManager = null) if ($eventManager) { $this->eventManager($eventManager); } - - // Compatibility with DispatcherFilters. - foreach (DispatcherFactory::filters() as $filter) { - $this->addFilter($filter); - } $this->factory = $factory ?: new ControllerFactory(); } diff --git a/tests/TestCase/Http/ActionDispatcherTest.php b/tests/TestCase/Http/ActionDispatcherTest.php index 5b221a0a5a2..18fc999f553 100644 --- a/tests/TestCase/Http/ActionDispatcherTest.php +++ b/tests/TestCase/Http/ActionDispatcherTest.php @@ -19,7 +19,6 @@ use Cake\Network\Request; use Cake\Network\Response; use Cake\Network\Session; -use Cake\Routing\DispatcherFactory; use Cake\Routing\Filter\ControllerFactoryFilter; use Cake\Routing\Router; use Cake\TestSuite\TestCase; @@ -43,17 +42,6 @@ public function setUp() $this->dispatcher->addFilter(new ControllerFactoryFilter()); } - /** - * Teardown - * - * @return void - */ - public function tearDown() - { - parent::tearDown(); - DispatcherFactory::clear(); - } - /** * Ensure the constructor args end up on the right protected properties. * @@ -69,22 +57,6 @@ public function testConstructorArgs() $this->assertAttributeSame($factory, 'factory', $dispatcher); } - /** - * Ensure that filters connected to the DispatcherFactory are - * also applied - */ - public function testDispatcherFactoryCompat() - { - $filter = $this->getMock( - 'Cake\Routing\DispatcherFilter', - ['beforeDispatch', 'afterDispatch'] - ); - DispatcherFactory::add($filter); - $dispatcher = new ActionDispatcher(); - $this->assertCount(1, $dispatcher->getFilters()); - $this->assertSame($filter, $dispatcher->getFilters()[0]); - } - /** * Test adding routing filters *