public function publishPageRevision(
        $siteId,
        $pageName,
        $pageType,
        $revisionId,
        string $modifiedByUserId,
        string $modifiedReason = Tracking::UNKNOWN_REASON
    ) {
        //Query is needed to ensure revision belongs to the page in question
        $pageQueryBuilder = $this->_em->createQueryBuilder();
        $pageQueryBuilder->select('page, revision')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->join('page.revisions', 'revision')
            ->where('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->andWhere('page.site = :siteId')
            ->andWhere('revision.revisionId = :revisionId')
            ->setParameter('pageName', $pageName)
            ->setParameter('pageType', $pageType)
            ->setParameter('siteId', $siteId)
            ->setParameter('revisionId', $revisionId);

        try {
            /** @var \Rcm\Entity\Page $page */
            $page = $pageQueryBuilder->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            throw new PageNotFoundException(
                'Unable to locate page by revision. ' . json_encode([
                    'revisionId' => $revisionId,
                    'siteId' => $siteId,
                    'pageName' => $pageName,
                    'pageType' => $pageType,
                ])
            );
        }

        $revision = $page->getRevisionById($revisionId);

        if (empty($revision)) {
            throw new RuntimeException(
                'Revision not found. ' . json_encode([
                    'revisionId' => $revisionId,
                    'pageId' => $page->getPageId()
                ])
            );
        }

        $page->setPublishedRevision($revision);
        $page->setModifiedByUserId(
            $modifiedByUserId,
            $modifiedReason
        );

        $revision->setModifiedByUserId(
            $modifiedByUserId,
            $modifiedReason
        );

        $this->_em->flush(
            [
                $revision,
                $page
            ]
        );

        return $page;
    }
public function publishPageRevision(
        $siteId,
        $pageName,
        $pageType,
        $revisionId,
        string $modifiedByUserId,
        string $modifiedReason = Tracking::UNKNOWN_REASON
    ) {
        //Query is needed to ensure revision belongs to the page in question
        $pageQueryBuilder = $this->_em->createQueryBuilder();
        $pageQueryBuilder->select('page, revision')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->join('page.revisions', 'revision')
            ->where('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->andWhere('page.site = :siteId')
            ->andWhere('revision.revisionId = :revisionId')
            ->setParameter('pageName', $pageName)
            ->setParameter('pageType', $pageType)
            ->setParameter('siteId', $siteId)
            ->setParameter('revisionId', $revisionId);

        try {
            /** @var \Rcm\Entity\Page $page */
            $page = $pageQueryBuilder->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            throw new PageNotFoundException(
                'Unable to locate page by revision. ' . json_encode([
                    'revisionId' => $revisionId,
                    'siteId' => $siteId,
                    'pageName' => $pageName,
                    'pageType' => $pageType,
                ])
            );
        }

        $revision = $page->getRevisionById($revisionId);

        if (empty($revision)) {
            throw new RuntimeException(
                'Revision not found. ' . json_encode([
                    'revisionId' => $revisionId,
                    'pageId' => $page->getPageId()
                ])
            );
        }

        $page->setPublishedRevision($revision);
        $page->setModifiedByUserId(
            $modifiedByUserId,
            $modifiedReason
        );

        $revision->setModifiedByUserId(
            $modifiedByUserId,
            $modifiedReason
        );

        $this->_em->flush(
            [
                $revision,
                $page
            ]
        );

        return $page;
    }
public function publishPageRevision ( $ siteId , $ pageName , $ pageType , $ revisionId , string $ modifiedByUserId , string $ modifiedReason = Tracking :: UNKNOWN_REASON ) { //Query is needed to ensure revision belongs to the page in question $ pageQueryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ pageQueryBuilder -> select ( 'page, revision' ) -> from ( \ Rcm \ Entity \ Page :: class , 'page' ) -> join ( 'page.revisions' , 'revision' ) -> where ( 'page.name = :pageName' ) -> andWhere ( 'page.pageType = :pageType' ) -> andWhere ( 'page.site = :siteId' ) -> andWhere ( 'revision.revisionId = :revisionId' ) -> setParameter ( 'pageName' , $ pageName ) -> setParameter ( 'pageType' , $ pageType ) -> setParameter ( 'siteId' , $ siteId ) -> setParameter ( 'revisionId' , $ revisionId ) ; try { /** @var \Rcm\Entity\Page $page */ $ page = $ pageQueryBuilder -> getQuery ( ) -> getSingleResult ( ) ; } catch ( NoResultException $ e ) { throw new PageNotFoundException ( 'Unable to locate page by revision. ' . json_encode ( [ 'revisionId' => $ revisionId , 'siteId' => $ siteId , 'pageName' => $ pageName , 'pageType' => $ pageType , ] ) ) ; } $ revision = $ page -> getRevisionById ( $ revisionId ) ; if ( empty ( $ revision ) ) { throw new RuntimeException ( 'Revision not found. ' . json_encode ( [ 'revisionId' => $ revisionId , 'pageId' => $ page -> getPageId ( ) ] ) ) ; } $ page -> setPublishedRevision ( $ revision ) ; $ page -> setModifiedByUserId ( $ modifiedByUserId , $ modifiedReason ) ; $ revision -> setModifiedByUserId ( $ modifiedByUserId , $ modifiedReason ) ; $ this -> _em -> flush ( [ $ revision , $ page ] ) ; return $ page ; }
Get a page entity containing a Revision Id.

@param int $siteId Site Id
@param string $pageName Name of page
@param string $pageType Page Type
@param int $revisionId Revision Id to search for
@param string $modifiedByUserId
@param string $modifiedReason

@return \Rcm\Entity\Page
@throws PageNotFoundException
@throws RuntimeException
Get a page entity containing a Revision Id .