Computes the new parent id for the node being moved.

@return int
0
protected function parentId()
	{
		switch ( $this->position )
		{
			case 'root':
				return null;

			case 'child':
				return $this->target->getKey();

			default:
				return $this->target->getParentId();
		}
	}
346295
private function getIDK()
    {
        if (!$this->xml) {
            return false;
        }
        $IDK = $this->xml->getElementsByTagName('IDK')->item(0);
        return $IDK ? (int)$IDK->nodeValue : false;
    }
1041338
protected function getParentsHierarchyField() {
		// see if we've got Parent values
        $parents = array();

        $parent = $this->owner;
        while ($parent && $parent->ParentID) {
            $parents[] = (int) $parent->ParentID;
            $parent = $parent->Parent();
            // fix for odd behaviour - in some instance a node is being assigned as its own parent. 
            if ($parent->ParentID == $parent->ID) {
                $parent = null;
            }
        }
        return $parents;
	}
931143
public function getParentId()
    {
        return (is_string($this->parentAttribute) && !empty($this->parentAttribute)) ?
        $this->{$this->parentAttribute} : null;
    }
305231
function () {

            // This check looks a little strange, but it suits what we're trying
            // to do: as we're walking through the children, a child node that has moved
            // from one parent to another will be found but would look like some kind
            // of insert. The check that we're doing here is looking up the current
            // child's ID in the *old* map and seeing if this child used to have a
            // different parent.
            var possiblyMovedElement = oldNodeMap[newChild.tagID];
            if (possiblyMovedElement &&
                    newParent.tagID !== getParentID(possiblyMovedElement)) {
                newEdit = {
                    type: "elementMove",
                    tagID: newChild.tagID,
                    parentID: newChild.parent.tagID
                };
                moves.push(newEdit.tagID);
                newEdits.push(newEdit);

                // this element in the new tree was a move to this spot, so we can move
                // on to the next child in the new tree.
                newIndex++;
                return true;
            }
            return false;
        }
995157
public function getId()
	{
		// Check for current asset id and compute other vars
		$current  = $this->model->get('asset_id', null);
		$parentId = $this->getAssetParentId();
		$name     = $this->getAssetName();
		$title    = $this->getAssetTitle();
		$title    = $title ?: $name;

		// Get model for assets
		$asset = Model::oneByName($name);

		// Re-inject the asset id into the model
		$this->model->set('asset_id', $asset->get('id'));

		// Prepare the asset to be stored
		$asset->set('parent_id', $parentId);
		$asset->set('name', $name);
		$asset->set('title', $title);

		if ($this->model->assetRules instanceof \JAccessRules || $this->model->assetRules instanceof \Hubzero\Access\Rules)
		{
			$asset->set('rules', (string)$this->model->assetRules);
		}

		// Specify how a new or moved node asset is inserted into the tree
		if (!$this->model->get('asset_id', null) || $asset->parent_id != $parentId)
		{
			$parent = Model::one($parentId);

			if (!$asset->saveAsLastChildOf($parent))
			{
				return false;
			}
		}
		elseif (!$asset->save())
		{
			return false;
		}

		// Register an event to update the asset name once we know the model id
		if ($this->model->isNew())
		{
			$me = $this;
			\Event::listen(
				function($event) use ($asset, $me)
				{
					$asset->set('name', $me->getAssetName());
					$asset->save();
				},
				$this->model->getTableName() . '_new'
			);
		}

		// Return the id
		return (int)$asset->get('id');
	}
268805
public static function getRootId()
	{
		$result = self::all()
			->whereEquals('parent_id', 0)
			->row();

		if (!$result->get('id'))
		{
			$result = self::all()
				->whereEquals('lft', 0)
				->row();

			if (!$result->get('id'))
			{
				$result = self::all()
					->whereEquals('alias', 'root.1')
					->row();
			}
		}

		return $result->get('id');
	}
1135441
public function nextNodeSibling($nID)
    {
        //if ($nID == $this->tree->TreeLastPage) return -37;
        if (!$this->hasNode($nID) || $this->allNodes[$nID]->parentID <= 0) {
            return -3;
        }
        $nodeOverride = $this->moveNextOverride($nID);
        if ($nodeOverride > 0) {
            return $nodeOverride;
        }
        $nextSibling = SLNode::where('NodeTree', $this->treeID)
            ->where('NodeParentID', $this->allNodes[$nID]->parentID)
            ->where('NodeParentOrder', (1+$this->allNodes[$nID]->parentOrd))
            ->select('NodeID')
            ->first();
        if ($nextSibling && isset($nextSibling->NodeID)) {
            return $nextSibling->NodeID;
        }
        return $this->nextNodeSibling($this->allNodes[$nID]->parentID);
    }
1357894
public function getLevel()
    {
        if ($this->_level !== null) {
            return $this->_level;
        }

        if ($this->isRoot()) {
            $this->_level = -1;
            return $this->_level;
        }

        $parents = array($this);
        $node = $this;

        while ($parent = $node->getParent()){
            if (!$parent->isRoot()) {
                $parents[] = $parent;
            }
            $node = $parent;
        }

        $this->_level = count($parents);

        return $this->_level;
    }
886992
public function getSumChildCount(): int
    {
        $count = count($this->children);

        foreach ($this->children as $node) {
            $count += $node->getChildCount();
        }

        return $count;
    }
185725
protected function insertNode()
    {
        $descendant = $this->getKey();
        $ancestor = (isset($this->parent_id) ? $this->parent_id : $descendant);

        $this->closure->insertNode($ancestor, $descendant);
    }
412744
public function detectParent()
    {
        // Look for a string, then a number (the parent id), followed by a non-action
        // string, then possiby a number and/or an action string and then the end
        $pattern = '#([a-z-]+)/(\d+)/(?!'.implode('|', $this->actions).')[a-z-]+(?:/\d+)?(/('.implode('|', $this->actions).'))?$#i';
        if (preg_match($pattern, $this->path, $matches)) {
            return [$matches[1], $matches[2]];
        }

        return false;
    }
985559
public function parent() {
		$parent = $this->domnode;
		if(!$parent)
			return new Node(null);
		while(true) {
			$parent = $parent->parentNode;
			if(!$parent)
				return;
			if($parent->nodeType == XML_ELEMENT_NODE)
				return new Node($parent);
		}
	}
317951
public function getParentEntityDescriptor()
    {
        if (is_null($this->parentEntityDescriptor)) {
            $this->setParentEntityDescriptor(
                EntityDescriptorRegistry::getInstance()
                    ->getDescriptorFor($this->parentEntity)
            );
        }
        return $this->parentEntityDescriptor;
    }
644015
public function checkParent()
    {
        if ($this->id) {
            if ($this->id == $this->parent_id) {
                throw new ParentIsSelfException('Parent should not be self.');
            }

            $tree = $this->getTree($this->id);
            $childrenIds = array_column($tree, 'id');

            if (in_array($this->parent_id, $childrenIds)) {
                throw new ParentIsChildException('Parent should not be child.');
            }
        }

        return $this;
    }
576246
public function previousSibling()
    {
        if (is_null($this->parent)) {
            throw new ParentNotFoundException('Parent is not set for this node.');
        }

        return $this->parent->previousChild($this->id);
    }
943448
public static function trait_get_parent_table_field_id() {
		if (property_exists(get_class(), 'class_configuration') and isset(self::$class_configuration['parent_field_id'])) {
			return self::$class_configuration['parent_field_id'];
		} else {
			return strtolower((new \ReflectionClass(get_class()))->getParentClass()->getShortName() . '_id');
		}
	}