/** * Add parent node ids of a given parent and all it's parents to the parentIds * property for updating * * @param AppModel $model The model object that the behavior is attached to * @param integer $parentId * @access protected */ function _addParentIds(&$model, $parentId) { if (!$parentId) { return; } // Get the path to the parent $pathToParent = $model->getpath($parentId); // Get the Ids of the nodes in the path to parent $idsInPathToParent = Set::extract("/{$model->alias}/{$model->primaryKey}", $pathToParent); // Add these to the _parentIds property for updating in afterSave $this->_parentIds[$model->alias] = array_merge($this->_parentIds[$model->alias], $idsInPathToParent); // Remove duplicates $this->_parentIds[$model->alias] = array_unique($this->_parentIds[$model->alias]); }