public function removeNode($softDelete = true, $currNode = true) {
        /**
         * @var Tree $this
         * @var Tree $child
         */
        if ($softDelete) {
            $this->nodeRemovalErrors = [];
            $module = Yii::$app->controller->module;
            extract($module->treeStructure);
            extract($module->dataStructure);

            if ($this->isRemovableAll()) {
                $children = $this->children()->all();
                foreach ($children as $child) {
                    $child->active = false;
                    if (!$child->save()) {
                        /** @noinspection PhpUndefinedFieldInspection */
                        /** @noinspection PhpUndefinedVariableInspection */
                        $this->nodeRemovalErrors[] = [
                            'id' => $child->$keyAttribute,
                            'name' => $child->$nameAttribute,
                            'error' => $child->getFirstErrors(),
                        ];
                    }
                }
            }
            if ($currNode) {
                $this->active = false;

                if (!$this->save()) {
                    /** @noinspection PhpUndefinedFieldInspection */
                    /** @noinspection PhpUndefinedVariableInspection */
                    $this->nodeRemovalErrors[] = [
                        'id' => $this->$keyAttribute,
                        'name' => $this->$nameAttribute,
                        'error' => $this->getFirstErrors(),
                    ];
                    return false;
                }
            }

            return true;
        } else {
            return $this->removable_all || $this->isRoot() && $this->children()->count() == 0 ?
                    $this->deleteWithChildren() : $this->delete();
        }
    }
public function removeNode($softDelete = true, $currNode = true) {
        /**
         * @var Tree $this
         * @var Tree $child
         */
        if ($softDelete) {
            $this->nodeRemovalErrors = [];
            $module = Yii::$app->controller->module;
            extract($module->treeStructure);
            extract($module->dataStructure);

            if ($this->isRemovableAll()) {
                $children = $this->children()->all();
                foreach ($children as $child) {
                    $child->active = false;
                    if (!$child->save()) {
                        /** @noinspection PhpUndefinedFieldInspection */
                        /** @noinspection PhpUndefinedVariableInspection */
                        $this->nodeRemovalErrors[] = [
                            'id' => $child->$keyAttribute,
                            'name' => $child->$nameAttribute,
                            'error' => $child->getFirstErrors(),
                        ];
                    }
                }
            }
            if ($currNode) {
                $this->active = false;

                if (!$this->save()) {
                    /** @noinspection PhpUndefinedFieldInspection */
                    /** @noinspection PhpUndefinedVariableInspection */
                    $this->nodeRemovalErrors[] = [
                        'id' => $this->$keyAttribute,
                        'name' => $this->$nameAttribute,
                        'error' => $this->getFirstErrors(),
                    ];
                    return false;
                }
            }

            return true;
        } else {
            return $this->removable_all || $this->isRoot() && $this->children()->count() == 0 ?
                    $this->deleteWithChildren() : $this->delete();
        }
    }
public function removeNode ( $ softDelete = true , $ currNode = true ) { /**
         * @var Tree $this
         * @var Tree $child
         */ if ( $ softDelete ) { $ this -> nodeRemovalErrors = [ ] ; $ module = Yii :: $ app -> controller -> module ; extract ( $ module -> treeStructure ) ; extract ( $ module -> dataStructure ) ; if ( $ this -> isRemovableAll ( ) ) { $ children = $ this -> children ( ) -> all ( ) ; foreach ( $ children as $ child ) { $ child -> active = false ; if ( ! $ child -> save ( ) ) { /** @noinspection PhpUndefinedFieldInspection */ /** @noinspection PhpUndefinedVariableInspection */ $ this -> nodeRemovalErrors [ ] = [ 'id' => $ child -> $ keyAttribute , 'name' => $ child -> $ nameAttribute , 'error' => $ child -> getFirstErrors ( ) , ] ; } } } if ( $ currNode ) { $ this -> active = false ; if ( ! $ this -> save ( ) ) { /** @noinspection PhpUndefinedFieldInspection */ /** @noinspection PhpUndefinedVariableInspection */ $ this -> nodeRemovalErrors [ ] = [ 'id' => $ this -> $ keyAttribute , 'name' => $ this -> $ nameAttribute , 'error' => $ this -> getFirstErrors ( ) , ] ; return false ; } } return true ; } else { return $ this -> removable_all || $ this -> isRoot ( ) && $ this -> children ( ) -> count ( ) == 0 ? $ this -> deleteWithChildren ( ) : $ this -> delete ( ) ; } }
Removes a node

@param boolean $softDelete whether to soft delete or hard delete
@param boolean $currNode   whether to update the current node value also

@return boolean status of activation/inactivation
Removes a node