Vineet
Vineet

Reputation: 287

How to create a custom callback function in cakephp after saveAll()

I am developing an application in cakephp. In this application I am using saveAll() function at many different places to save multiple records. What is need is to create a callback function which automatically gets called after saveAll() is executed, as I think there is no predefined callback function in cakephp which gets called after saveAll(). I know there is a function afterSave(), which gets called after every save() action. What can be the solution. Any suggestions would really be appreciated. Thank you :)

Upvotes: 0

Views: 1437

Answers (2)

Lobo
Lobo

Reputation: 4157

You can redefine the saveAll function in your model as follows:

function saveAll($datos=null, $opciones = array()){
    parent::saveAll($datos, $opciones);
    $this->yourCallBackFunction();
}

function yourCallBackFunction(){
    //do something
}

Regards!

Upvotes: 1

deceze
deceze

Reputation: 522597

public function saveAll($data, $options) {
    $return = parent::saveAll($data, $options);

    // your callback code here

    return $return;
}

Upvotes: 1

Related Questions