Browse files

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

  • Loading branch information...
1 parent 98a32c3 commit 867d4b312dcefe92dea5bcb4f392970c3daef280 @bar bar committed Sep 10, 2013
View
3 lib/Cake/Model/Behavior/AclBehavior.php
@@ -97,9 +97,10 @@ public function node(Model $model, $ref = null, $type = null) {
*
* @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);
View
3 lib/Cake/Model/Behavior/TranslateBehavior.php
@@ -408,9 +408,10 @@ public function afterValidate(Model $Model) {
*
* @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;
}
View
3 lib/Cake/Model/Behavior/TreeBehavior.php
@@ -88,9 +88,10 @@ public function setup(Model $Model, $config = array()) {
*
* @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]) {
View
7 lib/Cake/Model/Model.php
@@ -3418,9 +3418,10 @@ public function afterFind($results, $primary = false) {
* 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 @@ public function beforeSave($options = array()) {
* 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()) {
}
/**
View
4 lib/Cake/Model/ModelBehavior.php
@@ -178,9 +178,11 @@ public function beforeSave(Model $model, $options = array()) {
*
* @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;
}
View
3 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
@@ -130,9 +130,10 @@ public function beforeSave(Model $model, $options = array()) {
*
* @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);
View
6 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'),
);

0 comments on commit 867d4b3

Please sign in to comment.