private function doPersistIfValid(Page $page)
    {
        if (null === $page->getParent() && !empty($this->persist)) {
            // If root, only persist
            $this->em->persist($page);
            return;
        }

        $method = '';
        if (self::PERSIST_AS_FIRST_CHILD === $this->persist) {
            $method = 'insertNodeAsFirstChildOf';
        } elseif (self::PERSIST_AS_LAST_CHILD === $this->persist) {
            $method = 'insertNodeAsLastChildOf';
        }

        if (!empty($method)) {
            $this->em->getRepository('BackBee\NestedNode\Page')->$method($page, $page->getParent(), $this->isSection);
            $this->em->persist($page);
        }
    }
private function doPersistIfValid(Page $page)
    {
        if (null === $page->getParent() && !empty($this->persist)) {
            // If root, only persist
            $this->em->persist($page);
            return;
        }

        $method = '';
        if (self::PERSIST_AS_FIRST_CHILD === $this->persist) {
            $method = 'insertNodeAsFirstChildOf';
        } elseif (self::PERSIST_AS_LAST_CHILD === $this->persist) {
            $method = 'insertNodeAsLastChildOf';
        }

        if (!empty($method)) {
            $this->em->getRepository('BackBee\NestedNode\Page')->$method($page, $page->getParent(), $this->isSection);
            $this->em->persist($page);
        }
    }
private function doPersistIfValid ( Page $ page ) { if ( null === $ page -> getParent ( ) && ! empty ( $ this -> persist ) ) { // If root, only persist $ this -> em -> persist ( $ page ) ; return ; } $ method = '' ; if ( self :: PERSIST_AS_FIRST_CHILD === $ this -> persist ) { $ method = 'insertNodeAsFirstChildOf' ; } elseif ( self :: PERSIST_AS_LAST_CHILD === $ this -> persist ) { $ method = 'insertNodeAsLastChildOf' ; } if ( ! empty ( $ method ) ) { $ this -> em -> getRepository ( 'BackBee\NestedNode\Page' ) -> $ method ( $ page , $ page -> getParent ( ) , $ this -> isSection ) ; $ this -> em -> persist ( $ page ) ; } }
Persists the page is need and valid

@param  Page                 $page               The page to be built.
Persists the page is need and valid