/** * afterSave is called after a model is saved. * * @param Model $model Model using this behavior * @param bool $created True if this save created a new record * @param array $options Options passed from Model::save(). * @return bool * @throws InternalErrorException * @see Model::save() */ public function afterSave(Model $model, $created, $options = array()) { $model->LanguagesPage->data['LanguagesPage']['page_id'] = $model->data['Page']['id']; if (!$model->LanguagesPage->save(null, false)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } if ($created) { if (!($result = $model->saveContainer($model->data))) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } $model->data = Hash::merge($model->data, $result); if (!($result = $model->saveBox($model->data))) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } $model->data = Hash::merge($model->data, $result); if (!($result = $model->saveContainersPage($model->data))) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } $model->data = Hash::merge($model->data, $result); if (!($result = $model->saveBoxesPage($model->data))) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } $model->data = Hash::merge($model->data, $result); } return parent::afterSave($model, $created, $options); }