public function updateRootContentSetByPage(Page $page, ContentSet $oldContentSet, ContentSet $newContentSet, BBUserToken $userToken)
    {
        $em = $this->_em;
        $q = $this->createQueryBuilder('c');
        $results = $q->leftJoin('c._pages', 'p')
                        ->leftJoin('p._section', 'sp')
                        ->leftJoin('c._subcontent', 'subcontent')
                        ->where('subcontent = :contentToReplace')
                        ->andWhere('sp._root = :cpageRoot')
                        ->andWhere('sp._leftnode > :cpageLeftnode')
                        ->andWhere('sp._rightnode < :cpageRightnode')
                        ->setParameters([
                            'contentToReplace' => $oldContentSet,
                            'cpageRoot' => $page->getSection()->getRoot(),
                            'cpageLeftnode' => $page->getLeftnode(),
                            'cpageRightnode' => $page->getRightnode(),
                        ])
                        ->getQuery()->getResult()
        ;

        if ($results) {
            foreach ($results as $parentContentSet) {
                /* create draft for the main container */
                $draft = $em->getRepository('BackBee\ClassContent\Revision')->getDraft(
                    $parentContentSet,
                    $userToken,
                    true
                );

                if (null !== $draft) {
                    $parentContentSet->setDraft($draft);
                }

                /* Replace the old ContentSet by the new one */
                $parentContentSet->replaceChildBy($oldContentSet, $newContentSet);
                $em->persist($parentContentSet);
            }
        }
    }
public function updateRootContentSetByPage(Page $page, ContentSet $oldContentSet, ContentSet $newContentSet, BBUserToken $userToken)
    {
        $em = $this->_em;
        $q = $this->createQueryBuilder('c');
        $results = $q->leftJoin('c._pages', 'p')
                        ->leftJoin('p._section', 'sp')
                        ->leftJoin('c._subcontent', 'subcontent')
                        ->where('subcontent = :contentToReplace')
                        ->andWhere('sp._root = :cpageRoot')
                        ->andWhere('sp._leftnode > :cpageLeftnode')
                        ->andWhere('sp._rightnode < :cpageRightnode')
                        ->setParameters([
                            'contentToReplace' => $oldContentSet,
                            'cpageRoot' => $page->getSection()->getRoot(),
                            'cpageLeftnode' => $page->getLeftnode(),
                            'cpageRightnode' => $page->getRightnode(),
                        ])
                        ->getQuery()->getResult()
        ;

        if ($results) {
            foreach ($results as $parentContentSet) {
                /* create draft for the main container */
                $draft = $em->getRepository('BackBee\ClassContent\Revision')->getDraft(
                    $parentContentSet,
                    $userToken,
                    true
                );

                if (null !== $draft) {
                    $parentContentSet->setDraft($draft);
                }

                /* Replace the old ContentSet by the new one */
                $parentContentSet->replaceChildBy($oldContentSet, $newContentSet);
                $em->persist($parentContentSet);
            }
        }
    }
public function updateRootContentSetByPage ( Page $ page , ContentSet $ oldContentSet , ContentSet $ newContentSet , BBUserToken $ userToken ) { $ em = $ this -> _em ; $ q = $ this -> createQueryBuilder ( 'c' ) ; $ results = $ q -> leftJoin ( 'c._pages' , 'p' ) -> leftJoin ( 'p._section' , 'sp' ) -> leftJoin ( 'c._subcontent' , 'subcontent' ) -> where ( 'subcontent = :contentToReplace' ) -> andWhere ( 'sp._root = :cpageRoot' ) -> andWhere ( 'sp._leftnode > :cpageLeftnode' ) -> andWhere ( 'sp._rightnode < :cpageRightnode' ) -> setParameters ( [ 'contentToReplace' => $ oldContentSet , 'cpageRoot' => $ page -> getSection ( ) -> getRoot ( ) , 'cpageLeftnode' => $ page -> getLeftnode ( ) , 'cpageRightnode' => $ page -> getRightnode ( ) , ] ) -> getQuery ( ) -> getResult ( ) ; if ( $ results ) { foreach ( $ results as $ parentContentSet ) { /* create draft for the main container */ $ draft = $ em -> getRepository ( 'BackBee\ClassContent\Revision' ) -> getDraft ( $ parentContentSet , $ userToken , true ) ; if ( null !== $ draft ) { $ parentContentSet -> setDraft ( $ draft ) ; } /* Replace the old ContentSet by the new one */ $ parentContentSet -> replaceChildBy ( $ oldContentSet , $ newContentSet ) ; $ em -> persist ( $ parentContentSet ) ; } } }
Replace root contentset for a page and its descendants.

@param \BackBee\NestedNode\Page            $page
@param \BackBee\ClassContent\ContentSet    $oldContentSet
@param \BackBee\ClassContent\ContentSet    $newContentSet
@param \BackBee\Security\Token\BBUserToken $userToken
Replace root contentset for a page and its descendants .