public function createRoot(Node $node)
    {
        if($node instanceof NodeWrapper)
        {
            throw new \InvalidArgumentException('Can\'t create a root node from a NodeWrapper node');
        }

        $node->setLeftValue(1);
        $node->setRightValue(2);

        if($this->getConfiguration()->hasManyRoots())
        {
            $rootValue = $node->getId();
            if($rootValue === null)
            {
                // Set a temporary value in case wrapped node requires root value to be set
                $node->setRootValue(0);
                $this->getEntityManager()->persist($node);
                $this->getEntityManager()->flush();
                $rootValue = $node->getId();
            }

            if($rootValue === null)
            {
                // @codeCoverageIgnoreStart
                throw new \RuntimeException('Node must have an identifier available via getId()');
                // @codeCoverageIgnoreEnd
            }

            $node->setRootValue($rootValue);
        }


        $this->getEntityManager()->persist($node);
        $this->getEntityManager()->flush();

        return $this->wrapNode($node);
    }
public function createRoot(Node $node)
    {
        if($node instanceof NodeWrapper)
        {
            throw new \InvalidArgumentException('Can\'t create a root node from a NodeWrapper node');
        }

        $node->setLeftValue(1);
        $node->setRightValue(2);

        if($this->getConfiguration()->hasManyRoots())
        {
            $rootValue = $node->getId();
            if($rootValue === null)
            {
                // Set a temporary value in case wrapped node requires root value to be set
                $node->setRootValue(0);
                $this->getEntityManager()->persist($node);
                $this->getEntityManager()->flush();
                $rootValue = $node->getId();
            }

            if($rootValue === null)
            {
                // @codeCoverageIgnoreStart
                throw new \RuntimeException('Node must have an identifier available via getId()');
                // @codeCoverageIgnoreEnd
            }

            $node->setRootValue($rootValue);
        }


        $this->getEntityManager()->persist($node);
        $this->getEntityManager()->flush();

        return $this->wrapNode($node);
    }
public function createRoot ( Node $ node ) { if ( $ node instanceof NodeWrapper ) { throw new \ InvalidArgumentException ( 'Can\'t create a root node from a NodeWrapper node' ) ; } $ node -> setLeftValue ( 1 ) ; $ node -> setRightValue ( 2 ) ; if ( $ this -> getConfiguration ( ) -> hasManyRoots ( ) ) { $ rootValue = $ node -> getId ( ) ; if ( $ rootValue === null ) { // Set a temporary value in case wrapped node requires root value to be set $ node -> setRootValue ( 0 ) ; $ this -> getEntityManager ( ) -> persist ( $ node ) ; $ this -> getEntityManager ( ) -> flush ( ) ; $ rootValue = $ node -> getId ( ) ; } if ( $ rootValue === null ) { // @codeCoverageIgnoreStart throw new \ RuntimeException ( 'Node must have an identifier available via getId()' ) ; // @codeCoverageIgnoreEnd } $ node -> setRootValue ( $ rootValue ) ; } $ this -> getEntityManager ( ) -> persist ( $ node ) ; $ this -> getEntityManager ( ) -> flush ( ) ; return $ this -> wrapNode ( $ node ) ; }
Creates a new root node

@param Node

@return NodeWrapper
Creates a new root node