Exemple #1
0
 protected function afterUpdate()
 {
     if (!empty($this->__options['update_children'])) {
         if ($children = (new static())->setState('filter.parent', $this->_id)->getItems()) {
             foreach ($children as $child) {
                 $child->ancestors = array();
                 $child->path = null;
                 $child->update(array(), array('update_children' => true));
             }
         }
     }
     parent::afterUpdate();
 }
Exemple #2
0
 protected function afterUpdate()
 {
     if ($this->__oldNode->tree != $this->tree) {
         // update the tree value for this node and all descendants
         $result = $this->collection()->update(array('lft' => array('$gte' => $this->__oldNode->lft, '$lte' => $this->__oldNode->rgt), 'tree' => $this->__oldNode->tree), array('$set' => array('tree' => $this->tree)), array('multiple' => true));
     }
     if ($this->__update_children) {
         if ($children = (new static())->setState('filter.parent', $this->id)->getList()) {
             foreach ($children as $child) {
                 $child->tree = $this->tree;
                 $child->path = null;
                 $child->__update_children = true;
                 $child->save();
             }
         }
     }
     if (!empty($this->__isMoving)) {
         $this->rebuildTree($this->tree);
         // if we just removed a leaf/branch to a new tree, rebuild the old tree too
         if (!empty($this->__oldNode) && $this->tree != $this->__oldNode->tree) {
             $this->rebuildTree($this->__oldNode->tree);
         }
     }
     return parent::afterUpdate();
 }