Skip to content

Commit

Permalink
Don't double bind dispatch filters.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markstory committed Apr 19, 2016
1 parent 268de40 commit 366484c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
5 changes: 0 additions & 5 deletions src/Http/ActionDispatcher.php
Expand Up @@ -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();
}

Expand Down
28 changes: 0 additions & 28 deletions tests/TestCase/Http/ActionDispatcherTest.php
Expand Up @@ -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;
Expand All @@ -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.
*
Expand All @@ -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
*
Expand Down

0 comments on commit 366484c

Please sign in to comment.