Browse Source

Renaming a few things in dispatcher filters to maccht general naming style in CakePHP

Jose Lorenzo Rodriguez 14 years ago
parent
commit
70f3cc579c

+ 5 - 5
lib/Cake/Routing/Dispatcher.php

@@ -80,7 +80,7 @@ class Dispatcher implements CakeEventListener {
  **/
 	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 @@ class Dispatcher implements CakeEventListener {
 				$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 @@ class Dispatcher implements CakeEventListener {
  * @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 @@ class Dispatcher implements CakeEventListener {
 			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();
 	}

+ 4 - 4
lib/Cake/Routing/DispatcherFilter.php

@@ -45,8 +45,8 @@ abstract class DispatcherFilter implements CakeEventListener {
  **/
 	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 @@ abstract class DispatcherFilter implements CakeEventListener {
  *	keys in the data property.
  * @return CakeResponse|boolean
  **/
-	public function preDispatch($event) {
+	public function beforeDispatch($event) {
 	}
 
 /**
@@ -81,5 +81,5 @@ abstract class DispatcherFilter implements CakeEventListener {
  *	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) {}
 }

+ 2 - 2
lib/Cake/Test/Case/Routing/DispatcherTest.php

@@ -1269,7 +1269,7 @@ class DispatcherTest extends CakeTestCase {
 		$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 @@ class DispatcherTest extends CakeTestCase {
 		$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();

+ 2 - 2
lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/Routing/Filter/Test2DispatcherFilter.php

@@ -20,13 +20,13 @@ App::uses('DispatcherFilter', 'Routing');
 
 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);
 	}
 

+ 2 - 2
lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/Routing/Filter/TestDispatcherFilter.php

@@ -20,11 +20,11 @@ App::uses('DispatcherFilter', 'Routing');
 
 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);
 	}