src/Helper/PageHelper.php
public function makePageSnapshot(PageInterface $page)
    {
        foreach ($page->getLayoutBlock() as $layoutBlock) {
            $layoutBlockContent = $this->registry->getManagerForClass($layoutBlock->getClassType())->getRepository($layoutBlock->getClassType())->find(
                $layoutBlock->getObjectId()
            );
            $layoutBlock->takeSnapshot($this->serializer->serialize($layoutBlockContent, 'json'));
        }

        $pageSnapshotClass = $this->pageSnapshotManager->getClassName();

        /** @var \Networking\InitCmsBundle\Model\PageSnapshotInterface $pageSnapshot */
        $pageSnapshot = new $pageSnapshotClass($page);
        $pageSnapshot->setVersionedData($this->serializer->serialize($page, 'json'))
            ->setPage($page);

        if ($oldPageSnapshot = $page->getSnapshot()) {
            $snapshotContentRoute = $oldPageSnapshot->getContentRoute();
        } else {
            $contentRouteClass = $this->contentRouteManager->getClassName();
            /** @var \Networking\InitCmsBundle\Model\ContentRouteInterface $snapshotContentRoute */
            $snapshotContentRoute = new $contentRouteClass();
        }

        $pageSnapshot->setContentRoute($snapshotContentRoute);
        $pageSnapshot->setPath(self::getPageRoutePath($page->getPath()));

        $om = $this->registry->getManagerForClass($pageSnapshotClass);
        $om->persist($pageSnapshot);
        $om->flush();

        $snapshotContentRoute->setPath(self::getPageRoutePath($page->getPath()));
        $snapshotContentRoute->setObjectId($pageSnapshot->getId());

        if ($oldPageSnapshot && ($oldPageSnapshot->getPath() != self::getPageRoutePath($page->getPath()))) {
            $this->phpCache->clean();
        }

        $om = $this->registry->getManagerForClass(get_class($snapshotContentRoute));
        $om->persist($snapshotContentRoute);
        $om->flush();
    }
public function makePageSnapshot(PageInterface $page)
    {
        foreach ($page->getLayoutBlock() as $layoutBlock) {
            $layoutBlockContent = $this->registry->getManagerForClass($layoutBlock->getClassType())->getRepository($layoutBlock->getClassType())->find(
                $layoutBlock->getObjectId()
            );
            $layoutBlock->takeSnapshot($this->serializer->serialize($layoutBlockContent, 'json'));
        }

        $pageSnapshotClass = $this->pageSnapshotManager->getClassName();

        /** @var \Networking\InitCmsBundle\Model\PageSnapshotInterface $pageSnapshot */
        $pageSnapshot = new $pageSnapshotClass($page);
        $pageSnapshot->setVersionedData($this->serializer->serialize($page, 'json'))
            ->setPage($page);

        if ($oldPageSnapshot = $page->getSnapshot()) {
            $snapshotContentRoute = $oldPageSnapshot->getContentRoute();
        } else {
            $contentRouteClass = $this->contentRouteManager->getClassName();
            /** @var \Networking\InitCmsBundle\Model\ContentRouteInterface $snapshotContentRoute */
            $snapshotContentRoute = new $contentRouteClass();
        }

        $pageSnapshot->setContentRoute($snapshotContentRoute);
        $pageSnapshot->setPath(self::getPageRoutePath($page->getPath()));

        $om = $this->registry->getManagerForClass($pageSnapshotClass);
        $om->persist($pageSnapshot);
        $om->flush();

        $snapshotContentRoute->setPath(self::getPageRoutePath($page->getPath()));
        $snapshotContentRoute->setObjectId($pageSnapshot->getId());

        if ($oldPageSnapshot && ($oldPageSnapshot->getPath() != self::getPageRoutePath($page->getPath()))) {
            $this->phpCache->clean();
        }

        $om = $this->registry->getManagerForClass(get_class($snapshotContentRoute));
        $om->persist($snapshotContentRoute);
        $om->flush();
    }
public function makePageSnapshot ( PageInterface $ page ) { foreach ( $ page -> getLayoutBlock ( ) as $ layoutBlock ) { $ layoutBlockContent = $ this -> registry -> getManagerForClass ( $ layoutBlock -> getClassType ( ) ) -> getRepository ( $ layoutBlock -> getClassType ( ) ) -> find ( $ layoutBlock -> getObjectId ( ) ) ; $ layoutBlock -> takeSnapshot ( $ this -> serializer -> serialize ( $ layoutBlockContent , 'json' ) ) ; } $ pageSnapshotClass = $ this -> pageSnapshotManager -> getClassName ( ) ; /** @var \Networking\InitCmsBundle\Model\PageSnapshotInterface $pageSnapshot */ $ pageSnapshot = new $ pageSnapshotClass ( $ page ) ; $ pageSnapshot -> setVersionedData ( $ this -> serializer -> serialize ( $ page , 'json' ) ) -> setPage ( $ page ) ; if ( $ oldPageSnapshot = $ page -> getSnapshot ( ) ) { $ snapshotContentRoute = $ oldPageSnapshot -> getContentRoute ( ) ; } else { $ contentRouteClass = $ this -> contentRouteManager -> getClassName ( ) ; /** @var \Networking\InitCmsBundle\Model\ContentRouteInterface $snapshotContentRoute */ $ snapshotContentRoute = new $ contentRouteClass ( ) ; } $ pageSnapshot -> setContentRoute ( $ snapshotContentRoute ) ; $ pageSnapshot -> setPath ( self :: getPageRoutePath ( $ page -> getPath ( ) ) ) ; $ om = $ this -> registry -> getManagerForClass ( $ pageSnapshotClass ) ; $ om -> persist ( $ pageSnapshot ) ; $ om -> flush ( ) ; $ snapshotContentRoute -> setPath ( self :: getPageRoutePath ( $ page -> getPath ( ) ) ) ; $ snapshotContentRoute -> setObjectId ( $ pageSnapshot -> getId ( ) ) ; if ( $ oldPageSnapshot && ( $ oldPageSnapshot -> getPath ( ) != self :: getPageRoutePath ( $ page -> getPath ( ) ) ) ) { $ this -> phpCache -> clean ( ) ; } $ om = $ this -> registry -> getManagerForClass ( get_class ( $ snapshotContentRoute ) ) ; $ om -> persist ( $ snapshotContentRoute ) ; $ om -> flush ( ) ; }
Create a snapshot of a given page.

@param PageInterface $page
Create a snapshot of a given page .