Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Renaming a few things in dispatcher filters to maccht general naming …

…style in CakePHP
  • Loading branch information...
commit 70f3cc579ccbf9844beb983f210f65ea4d2f0d41 1 parent 565a58f
@lorenzo lorenzo authored
View
10 lib/Cake/Routing/Dispatcher.php
@@ -80,7 +80,7 @@ public function getEventManager() {
**/
public function implementedEvents() {
return array(
- 'Dispatcher.before' => array(
+ 'Dispatcher.beforeDispatch' => array(
array('callable' => array($this, 'asset')),
array('callable' => array($this, 'cached')),
array('callable' => array($this, 'parseParams')),
@@ -116,9 +116,9 @@ protected function _attachFilters($manager) {
$on = strtolower($filter['on']);
$options = array();
if (isset($filter['priority'])) {
- $options['priority'] = $filter['priority'];
+ $options = array('priority' => $filter['priority']);
}
- $manager->attach($filter['callable'], 'Dispatcher.' . $on, $options);
+ $manager->attach($filter['callable'], 'Dispatcher.' . $on . 'Dispatch', $options);
}
}
}
@@ -142,7 +142,7 @@ protected function _attachFilters($manager) {
* @throws MissingControllerException When the controller is missing.
*/
public function dispatch(CakeRequest $request, CakeResponse $response, $additionalParams = array()) {
- $beforeEvent = new CakeEvent('Dispatcher.before', $this, compact('request', 'response', 'additionalParams'));
+ $beforeEvent = new CakeEvent('Dispatcher.beforeDispatch', $this, compact('request', 'response', 'additionalParams'));
$this->getEventManager()->dispatch($beforeEvent);
$request = $beforeEvent->data['request'];
@@ -169,7 +169,7 @@ public function dispatch(CakeRequest $request, CakeResponse $response, $addition
return $response->body();
}
- $afterEvent = new CakeEvent('Dispatcher.after', $this, compact('request', 'response'));
+ $afterEvent = new CakeEvent('Dispatcher.afterDispatch', $this, compact('request', 'response'));
$this->getEventManager()->dispatch($afterEvent);
$afterEvent->data['response']->send();
}
View
8 lib/Cake/Routing/DispatcherFilter.php
@@ -45,8 +45,8 @@
**/
public function implementedEvents() {
return array(
- 'Dispatcher.before' => array('callable' => 'preDispatch', 'priority' => $this->priority),
- 'Dispatcher.after' => array('callable' => 'postDispatch', 'priority' => $this->priority),
+ 'Dispatcher.beforeDispatch' => array('callable' => 'beforeDispatch', 'priority' => $this->priority),
+ 'Dispatcher.afterDispatch' => array('callable' => 'afterDispatch', 'priority' => $this->priority),
);
}
@@ -66,7 +66,7 @@ public function implementedEvents() {
* keys in the data property.
* @return CakeResponse|boolean
**/
- public function preDispatch($event) {
+ public function beforeDispatch($event) {
}
/**
@@ -81,5 +81,5 @@ public function preDispatch($event) {
* keys in the data property.
* @return mixed boolean to stop the event dispatching or null to continue
**/
- public function postDispatch($event) {}
+ public function afterDispatch($event) {}
}
View
4 lib/Cake/Test/Case/Routing/DispatcherTest.php
@@ -1269,7 +1269,7 @@ public function testDispatcherFilterCallable() {
$request = new CakeRequest('/');
$response = $this->getMock('CakeResponse', array('send'));
$dispatcher->dispatch($request, $response);
- $this->assertEquals('Dispatcher.before', $request->params['eventName']);
+ $this->assertEquals('Dispatcher.beforeDispatch', $request->params['eventName']);
$dispatcher = new TestDispatcher();
Configure::write('Dispatcher.filters', array(
@@ -1279,7 +1279,7 @@ public function testDispatcherFilterCallable() {
$request = new CakeRequest('/');
$response = $this->getMock('CakeResponse', array('send'));
$dispatcher->dispatch($request, $response);
- $this->assertEquals('Dispatcher.after', $request->params['eventName']);
+ $this->assertEquals('Dispatcher.afterDispatch', $request->params['eventName']);
// Test that it is possible to skip the route connection process
$dispatcher = new TestDispatcher();
View
4 lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/Routing/Filter/Test2DispatcherFilter.php
@@ -20,13 +20,13 @@
class Test2DispatcherFilter extends DispatcherFilter {
- public function preDispatch($event) {
+ public function beforeDispatch($event) {
$event->data['response']->statusCode(500);
$event->stopPropagation();
return $event->data['response'];
}
- public function postDispatch($event) {
+ public function afterDispatch($event) {
$event->data['response']->statusCode(200);
}
View
4 lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/Routing/Filter/TestDispatcherFilter.php
@@ -20,11 +20,11 @@
class TestDispatcherFilter extends DispatcherFilter {
- public function preDispatch($event) {
+ public function beforeDispatch($event) {
$event->data['request']->params['altered'] = true;
}
- public function postDispatch($event) {
+ public function afterDispatch($event) {
$event->data['response']->statusCode(304);
}
Please sign in to comment.
Something went wrong with that request. Please try again.