From 867d4b312dcefe92dea5bcb4f392970c3daef280 Mon Sep 17 00:00:00 2001 From: Ber Clausen Date: Mon, 9 Sep 2013 21:20:22 -0300 Subject: [PATCH] Update afterSave() callback signature to be PHP5.4+ compliant. --- lib/Cake/Model/Behavior/AclBehavior.php | 3 ++- lib/Cake/Model/Behavior/TranslateBehavior.php | 3 ++- lib/Cake/Model/Behavior/TreeBehavior.php | 3 ++- lib/Cake/Model/Model.php | 7 +++++-- lib/Cake/Model/ModelBehavior.php | 4 +++- lib/Cake/Test/Case/Model/BehaviorCollectionTest.php | 3 ++- lib/Cake/Test/Case/Model/models.php | 6 +++--- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Model/Behavior/AclBehavior.php b/lib/Cake/Model/Behavior/AclBehavior.php index f2234989f..053a0b7c0 100644 --- a/lib/Cake/Model/Behavior/AclBehavior.php +++ b/lib/Cake/Model/Behavior/AclBehavior.php @@ -97,9 +97,10 @@ class AclBehavior extends ModelBehavior { * * @param Model $model * @param boolean $created True if this is a new record + * @param array $options Options passed from Model::save(). * @return void */ - public function afterSave(Model $model, $created) { + public function afterSave(Model $model, $created, $options = array()) { $types = $this->_typeMaps[$this->settings[$model->name]['type']]; if (!is_array($types)) { $types = array($types); diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 2550b72d2..e6861fb6f 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -408,9 +408,10 @@ class TranslateBehavior extends ModelBehavior { * * @param Model $Model Model the callback is called on * @param boolean $created Whether or not the save created a record. + * @param array $options Options passed from Model::save(). * @return void */ - public function afterSave(Model $Model, $created) { + public function afterSave(Model $Model, $created, $options = array()) { if (!isset($this->runtime[$Model->alias]['beforeValidate']) && !isset($this->runtime[$Model->alias]['beforeSave'])) { return true; } diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 84af35833..9eb44d60a 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -88,9 +88,10 @@ class TreeBehavior extends ModelBehavior { * * @param Model $Model Model instance. * @param boolean $created indicates whether the node just saved was created or updated + * @param array $options Options passed from Model::save(). * @return boolean true on success, false on failure */ - public function afterSave(Model $Model, $created) { + public function afterSave(Model $Model, $created, $options = array()) { extract($this->settings[$Model->alias]); if ($created) { if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 449ca5c7a..b6af891a9 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -3418,9 +3418,10 @@ class Model extends Object implements CakeEventListener { * Called before each save operation, after validation. Return a non-true result * to halt the save. * - * @param array $options + * @param array $options Options passed from Model::save(). * @return boolean True if the operation should continue, false if it should abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave + * @see Model::save() */ public function beforeSave($options = array()) { return true; @@ -3430,10 +3431,12 @@ class Model extends Object implements CakeEventListener { * Called after each successful save operation. * * @param boolean $created True if this save created a new record + * @param array $options Options passed from Model::save(). * @return void * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave + * @see Model::save() */ - public function afterSave($created) { + public function afterSave($created, $options = array()) { } /** diff --git a/lib/Cake/Model/ModelBehavior.php b/lib/Cake/Model/ModelBehavior.php index 4ccfbfd00..a0af6ca50 100644 --- a/lib/Cake/Model/ModelBehavior.php +++ b/lib/Cake/Model/ModelBehavior.php @@ -178,9 +178,11 @@ class ModelBehavior extends Object { * * @param Model $model Model using this behavior * @param boolean $created True if this save created a new record + * @param array $options Options passed from Model::save(). * @return boolean + * @see Model::save() */ - public function afterSave(Model $model, $created) { + public function afterSave(Model $model, $created, $options = array()) { return true; } diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index fd5f3088a..966d9f344 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -130,9 +130,10 @@ class TestBehavior extends ModelBehavior { * * @param Model $model * @param boolean $created + * @param array $options Options passed from Model::save(). * @return void */ - public function afterSave(Model $model, $created) { + public function afterSave(Model $model, $created, $options = array()) { $settings = $this->settings[$model->alias]; if (!isset($settings['afterSave']) || $settings['afterSave'] === 'off') { return parent::afterSave($model, $created); diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index 41c66eaac..51b44ef80 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -2731,7 +2731,7 @@ class AfterTree extends NumberTree { */ public $actsAs = array('Tree'); - public function afterSave($created) { + public function afterSave($created, $options = array()) { if ($created && isset($this->data['AfterTree'])) { $this->data['AfterTree']['name'] = 'Six and One Half Changed in AfterTree::afterSave() but not in database'; } @@ -3473,7 +3473,7 @@ class TransactionTestModel extends CakeTestModel { public $useTable = 'samples'; - public function afterSave($created) { + public function afterSave($created, $options = array()) { $data = array( array('apple_id' => 1, 'name' => 'sample6'), ); @@ -3488,7 +3488,7 @@ class TransactionManyTestModel extends CakeTestModel { public $useTable = 'samples'; - public function afterSave($created) { + public function afterSave($created, $options = array()) { $data = array( array('apple_id' => 1, 'name' => 'sample6'), );