concrete/src/Tree/Node/Node.php
public static function add($parent = false)
    {
        $db = Database::connection();
        $treeNodeParentID = 0;
        $treeID = 0;
        $treeNodeDisplayOrder = 0;
        $inheritPermissionsFromTreeNodeID = 0;
        if (is_object($parent)) {
            $treeNodeParentID = $parent->getTreeNodeID();
            $treeID = $parent->getTreeID();
            $inheritPermissionsFromTreeNodeID = $parent->getTreeNodePermissionsNodeID();
            $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$treeNodeParentID]);
            $parent->updateDateModified();
        } else {
            $parent = null;
        }

        $treeNodeTypeHandle = uncamelcase(strrchr(get_called_class(), '\\'));

        $dateModified = Core::make('date')->toDB();
        $dateCreated = Core::make('date')->toDB();

        $type = TreeNodeType::getByHandle($treeNodeTypeHandle);
        $db->executeQuery(
            'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)',
            [
                $type->getTreeNodeTypeID(),
                $treeNodeParentID,
                $treeNodeDisplayOrder,
                $inheritPermissionsFromTreeNodeID,
                $dateModified,
                $dateCreated,
                $treeID,
            ]
        );
        $id = $db->lastInsertId();
        $node = self::getByID($id);

        if (!$inheritPermissionsFromTreeNodeID) {
            $node->setTreeNodePermissionsToOverride();
        }

        if ($parent !== null && $parent->childNodesLoaded) {
            $parent->childNodes[] = $node;
        }

        return $node;
    }
public static function add($parent = false)
    {
        $db = Database::connection();
        $treeNodeParentID = 0;
        $treeID = 0;
        $treeNodeDisplayOrder = 0;
        $inheritPermissionsFromTreeNodeID = 0;
        if (is_object($parent)) {
            $treeNodeParentID = $parent->getTreeNodeID();
            $treeID = $parent->getTreeID();
            $inheritPermissionsFromTreeNodeID = $parent->getTreeNodePermissionsNodeID();
            $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$treeNodeParentID]);
            $parent->updateDateModified();
        } else {
            $parent = null;
        }

        $treeNodeTypeHandle = uncamelcase(strrchr(get_called_class(), '\\'));

        $dateModified = Core::make('date')->toDB();
        $dateCreated = Core::make('date')->toDB();

        $type = TreeNodeType::getByHandle($treeNodeTypeHandle);
        $db->executeQuery(
            'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)',
            [
                $type->getTreeNodeTypeID(),
                $treeNodeParentID,
                $treeNodeDisplayOrder,
                $inheritPermissionsFromTreeNodeID,
                $dateModified,
                $dateCreated,
                $treeID,
            ]
        );
        $id = $db->lastInsertId();
        $node = self::getByID($id);

        if (!$inheritPermissionsFromTreeNodeID) {
            $node->setTreeNodePermissionsToOverride();
        }

        if ($parent !== null && $parent->childNodesLoaded) {
            $parent->childNodes[] = $node;
        }

        return $node;
    }
public static function add ( $ parent = false ) { $ db = Database :: connection ( ) ; $ treeNodeParentID = 0 ; $ treeID = 0 ; $ treeNodeDisplayOrder = 0 ; $ inheritPermissionsFromTreeNodeID = 0 ; if ( is_object ( $ parent ) ) { $ treeNodeParentID = $ parent -> getTreeNodeID ( ) ; $ treeID = $ parent -> getTreeID ( ) ; $ inheritPermissionsFromTreeNodeID = $ parent -> getTreeNodePermissionsNodeID ( ) ; $ treeNodeDisplayOrder = ( int ) $ db -> fetchColumn ( 'select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?' , [ $ treeNodeParentID ] ) ; $ parent -> updateDateModified ( ) ; } else { $ parent = null ; } $ treeNodeTypeHandle = uncamelcase ( strrchr ( get_called_class ( ) , '\\' ) ) ; $ dateModified = Core :: make ( 'date' ) -> toDB ( ) ; $ dateCreated = Core :: make ( 'date' ) -> toDB ( ) ; $ type = TreeNodeType :: getByHandle ( $ treeNodeTypeHandle ) ; $ db -> executeQuery ( 'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)' , [ $ type -> getTreeNodeTypeID ( ) , $ treeNodeParentID , $ treeNodeDisplayOrder , $ inheritPermissionsFromTreeNodeID , $ dateModified , $ dateCreated , $ treeID , ] ) ; $ id = $ db -> lastInsertId ( ) ; $ node = self :: getByID ( $ id ) ; if ( ! $ inheritPermissionsFromTreeNodeID ) { $ node -> setTreeNodePermissionsToOverride ( ) ; } if ( $ parent !== null && $ parent -> childNodesLoaded ) { $ parent -> childNodes [ ] = $ node ; } return $ node ; }
Add a new node.

@param Node|null|false $parent the parent node

@return Node
Add a new node .