Skip to content
Permalink
Browse files

Update Model/Behaviors callback signature to be PHP5.4+ compliant.

  • Loading branch information...
bar committed Sep 5, 2013
1 parent 77c453b commit c524645738e666bf4a298d15e6fd6f39d7c6992e
@@ -320,9 +320,11 @@ public function afterFind(Model $Model, $results, $primary) {
* beforeValidate Callback
*
* @param Model $Model Model invalidFields was called on.
* @param array $options Options passed from Model::save().
* @return boolean
* @see Model::save()
*/
public function beforeValidate(Model $Model) {
public function beforeValidate(Model $Model, $options = array()) {
unset($this->runtime[$Model->alias]['beforeSave']);
$this->_setRuntimeData($Model);
return true;
@@ -335,7 +337,9 @@ public function beforeValidate(Model $Model) {
* disabled. Or the runtime data hasn't been set yet.
*
* @param Model $Model Model save was called on.
* @param array $options Options passed from Model::save().
* @return boolean true.
* @see Model::save()
*/
public function beforeSave(Model $Model, $options = array()) {
if (isset($options['validate']) && !$options['validate']) {
@@ -175,9 +175,11 @@ public function afterDelete(Model $Model) {
*
* @since 1.2
* @param Model $Model Model instance
* @param array $options Options passed from Model::save().
* @return boolean true to continue, false to abort the save
* @see Model::save()
*/
public function beforeSave(Model $Model) {
public function beforeSave(Model $Model, $options = array()) {
extract($this->settings[$Model->alias]);
$this->_addToWhitelist($Model, array($left, $right));
@@ -3460,9 +3460,10 @@ public function afterDelete() {
* Called during validation operations, before validation. Please note that custom
* validation rules can be defined in $validate.
*
* @param array $options Options passed from model::save(), see $options of model::save().
* @param array $options Options passed from Model::save().
* @return boolean True if validate operation should continue, false to abort
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
* @see Model::save()
*/
public function beforeValidate($options = array()) {
return true;
@@ -141,9 +141,11 @@ public function afterFind(Model $model, $results, $primary) {
* will allow you to make the validation fail.
*
* @param Model $model Model using this behavior
* @param array $options Options passed from Model::save().
* @return mixed False or null will abort the operation. Any other result will continue.
* @see Model::save()
*/
public function beforeValidate(Model $model) {
public function beforeValidate(Model $model, $options = array()) {
return true;
}
@@ -163,9 +165,11 @@ public function afterValidate(Model $model) {
* will abort the save operation.
*
* @param Model $model Model using this behavior
* @param array $options Options passed from Model::save().
* @return mixed False if the operation should abort. Any other result will continue.
* @see Model::save()
*/
public function beforeSave(Model $model) {
public function beforeSave(Model $model, $options = array()) {
return true;
}
@@ -104,10 +104,12 @@ public function afterFind(Model $model, $results, $primary) {
/**
* beforeSave method
*
* @param Model $model
* @return void
* @param Model $model Model using this behavior
* @param array $options Options passed from Model::save().
* @return mixed False if the operation should abort. Any other result will continue.
* @see Model::save()
*/
public function beforeSave(Model $model) {
public function beforeSave(Model $model, $options = array()) {
$settings = $this->settings[$model->alias];
if (!isset($settings['beforeSave']) || $settings['beforeSave'] === 'off') {
return parent::beforeSave($model);
@@ -155,12 +157,14 @@ public function afterSave(Model $model, $created) {
}
/**
* beforeValidate method
* beforeValidate Callback
*
* @param Model $model
* @return void
* @param Model $Model Model invalidFields was called on.
* @param array $options Options passed from Model::save().
* @return boolean
* @see Model::save()
*/
public function beforeValidate(Model $model) {
public function beforeValidate(Model $model, $options = array()) {
$settings = $this->settings[$model->alias];
if (!isset($settings['validate']) || $settings['validate'] === 'off') {
return parent::beforeValidate($model);
@@ -2039,7 +2039,9 @@ public function beforeSave($options = array()) {
/**
* beforeValidate callback
*
* @return boolean
* @param array $options Options passed from Model::save().
* @return boolean True if validate operation should continue, false to abort
* @see Model::save()
*/
public function beforeValidate($options = array()) {
return $this->beforeValidateReturn;
@@ -4980,7 +4982,9 @@ protected function _findUnPublished($state, $query, $results = array()) {
/**
* Alters title data
*
* @return void
* @param array $options Options passed from Model::save().
* @return boolean True if validate operation should continue, false to abort
* @see Model::save()
*/
public function beforeValidate($options = array()) {
$this->data[$this->alias]['title'] = 'foo';

0 comments on commit c524645

Please sign in to comment.
You can’t perform that action at this time.