/** * Before delete method. Called before all deletes * * Will delete the current node and all children using the deleteAll method and sync the table. * * If scoped it will automatically set the needed scope data for the extended TreeBehavior. * * @param AppModel $Model Model instance * @return boolean true to continue, false to abort the delete * @access public */ public function beforeDelete($Model) { if ($this->scoped($Model)) { $this->__setScope($Model); } if ($this->counterCacheEnabled($Model)) { $this->__parentId = $Model->field($this->settings[$Model->alias]['parent']); } return parent::beforeDelete($Model); }
/** * Identifies the ids of the nodes whose counter caches need updating. I.e. * all parents of the current node * * @param AppModel $model The model object that the behavior is attached to * @return boolean Always true * @access public */ function beforeDelete(&$model) { $this->_parentIds[$model->alias] = array(); // Get parent before delete logic out of the way parent::beforeDelete($model); // Get the current/previous parent id $currentParentId = $model->field($this->settings[$model->alias]['parent']); // Add the current/previous parent id and it's parents to the _parentIds // property for updating in afterSave $this->_addParentIds($model, $currentParentId); return true; }