Merge pull request #4614 from wisoot/patch-1

Fix dispatch filters that have regular string as a key
This commit is contained in:
Mark Story 2014-09-15 08:18:20 -04:00
commit d34ff71e50
2 changed files with 11 additions and 1 deletions

View file

@ -97,7 +97,7 @@ class Dispatcher implements CakeEventListener {
foreach ($filters as $index => $filter) {
$settings = array();
if (is_array($filter) && !is_int($index)) {
if (is_array($filter) && !is_int($index) && class_exists($index)) {
$settings = $filter;
$filter = $index;
}

View file

@ -1328,6 +1328,16 @@ class DispatcherTest extends CakeTestCase {
$dispatcher->dispatch($request, $response);
$this->assertEquals('Dispatcher.afterDispatch', $request->params['eventName']);
$dispatcher = new TestDispatcher();
Configure::write('Dispatcher.filters', array(
'filterTest' => array('callable' => array($dispatcher, 'filterTest'), 'on' => 'before')
));
$request = new CakeRequest('/');
$response = $this->getMock('CakeResponse', array('send'));
$dispatcher->dispatch($request, $response);
$this->assertEquals('Dispatcher.beforeDispatch', $request->params['eventName']);
// Test that it is possible to skip the route connection process
$dispatcher = new TestDispatcher();
Configure::write('Dispatcher.filters', array(