Adding propagation of $cascade parameter (indicating if dependent records will be deleted as well) to beforeDelete callback at the Model and Behavior level

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6074 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-11-25 05:14:07 +00:00
parent caefdbb6d7
commit 085982c5f8
2 changed files with 6 additions and 4 deletions

View file

@ -112,10 +112,11 @@ class ModelBehavior extends Object {
* Before delete callback
*
* @param object $model Model using this behavior
* @param boolean $cascade If true records that depend on this record will also be deleted
* @return boolean True if the operation should continue, false if it should abort
* @access public
*/
function beforeDelete(&$model) { }
function beforeDelete(&$model, $cascade = true) { }
/**
* After delete callback
*

View file

@ -1305,14 +1305,14 @@ class Model extends Overloadable {
}
$id = $this->id;
if ($this->exists() && $this->beforeDelete()) {
if ($this->exists() && $this->beforeDelete($cascade)) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
if (!empty($this->behaviors)) {
$behaviors = array_keys($this->behaviors);
$ct = count($behaviors);
for ($i = 0; $i < $ct; $i++) {
if ($this->behaviors[$behaviors[$i]]->beforeDelete($this) === false) {
if ($this->behaviors[$behaviors[$i]]->beforeDelete($this, $cascade) === false) {
return false;
}
}
@ -2261,10 +2261,11 @@ class Model extends Overloadable {
/**
* Before delete callback
*
* @param boolean $cascade If true records that depend on this record will also be deleted
* @return boolean True if the operation should continue, false if it should abort
* @access public
*/
function beforeDelete() {
function beforeDelete($cascade = true) {
return true;
}
/**