Browse Source

Merge pull request #1623 from bar/php54-afterFind

Update afterFind() callback signature to be PHP5.4+ compliant.
ADmad 12 years ago
parent
commit
e77a75147f

+ 1 - 1
lib/Cake/Model/Behavior/TranslateBehavior.php

@@ -275,7 +275,7 @@ class TranslateBehavior extends ModelBehavior {
  * @param boolean $primary Did the find originate on $model.
  * @param boolean $primary Did the find originate on $model.
  * @return array Modified results
  * @return array Modified results
  */
  */
-	public function afterFind(Model $Model, $results, $primary) {
+	public function afterFind(Model $Model, $results, $primary = false) {
 		$Model->virtualFields = $this->runtime[$Model->alias]['virtualFields'];
 		$Model->virtualFields = $this->runtime[$Model->alias]['virtualFields'];
 		$this->runtime[$Model->alias]['virtualFields'] = $this->runtime[$Model->alias]['fields'] = array();
 		$this->runtime[$Model->alias]['virtualFields'] = $this->runtime[$Model->alias]['fields'] = array();
 		$locale = $this->_getLocale($Model);
 		$locale = $this->_getLocale($Model);

+ 3 - 3
lib/Cake/Model/Model.php

@@ -3392,12 +3392,12 @@ class Model extends Object implements CakeEventListener {
  * Called before each find operation. Return false if you want to halt the find
  * Called before each find operation. Return false if you want to halt the find
  * call, otherwise return the (modified) query data.
  * call, otherwise return the (modified) query data.
  *
  *
- * @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
+ * @param array $query Data used to execute this query, i.e. conditions, order, etc.
  * @return mixed true if the operation should continue, false if it should abort; or, modified
  * @return mixed true if the operation should continue, false if it should abort; or, modified
- *               $queryData to continue with new $queryData
+ *  $query to continue with new $query
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforefind
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforefind
  */
  */
-	public function beforeFind($queryData) {
+	public function beforeFind($query) {
 		return true;
 		return true;
 	}
 	}
 
 

+ 1 - 1
lib/Cake/Model/ModelBehavior.php

@@ -132,7 +132,7 @@ class ModelBehavior extends Object {
  * @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
  * @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
  * @return mixed An array value will replace the value of $results - any other value will be ignored.
  * @return mixed An array value will replace the value of $results - any other value will be ignored.
  */
  */
-	public function afterFind(Model $model, $results, $primary) {
+	public function afterFind(Model $model, $results, $primary = false) {
 	}
 	}
 
 
 /**
 /**

+ 1 - 1
lib/Cake/Test/Case/Model/BehaviorCollectionTest.php

@@ -84,7 +84,7 @@ class TestBehavior extends ModelBehavior {
  * @param boolean $primary
  * @param boolean $primary
  * @return void
  * @return void
  */
  */
-	public function afterFind(Model $model, $results, $primary) {
+	public function afterFind(Model $model, $results, $primary = false) {
 		$settings = $this->settings[$model->alias];
 		$settings = $this->settings[$model->alias];
 		if (!isset($settings['afterFind']) || $settings['afterFind'] === 'off') {
 		if (!isset($settings['afterFind']) || $settings['afterFind'] === 'off') {
 			return parent::afterFind($model, $results, $primary);
 			return parent::afterFind($model, $results, $primary);