Update afterFind() callback signature to be PHP5.4+ compliant.

This commit is contained in:
Ber Clausen 2013-09-10 09:33:11 -03:00
parent 994a5b00b6
commit 0a52061d86
4 changed files with 6 additions and 6 deletions

View file

@ -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);

View file

@ -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;
} }

View file

@ -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) {
} }
/** /**

View file

@ -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);