public function newInstanceIfHasRevision(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var ContainerInterface|ContainerAbstract $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        $publishedRevision = $new->getPublishedRevision();

        if (empty($publishedRevision)) {
            return null;
        }

        $new->lastPublished = new \DateTime();

        $new->revisions = new ArrayCollection();
        $new->stagedRevision = null;
        $new->stagedRevisionId = null;

        $new->setPublishedRevision(
            $publishedRevision->newInstance(
                $createdByUserId,
                $createdReason
            )
        );

        return $new;
    }
public function newInstanceIfHasRevision(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON
    ) {
        /** @var ContainerInterface|ContainerAbstract $new */
        $new = parent::newInstance(
            $createdByUserId,
            $createdReason
        );

        $publishedRevision = $new->getPublishedRevision();

        if (empty($publishedRevision)) {
            return null;
        }

        $new->lastPublished = new \DateTime();

        $new->revisions = new ArrayCollection();
        $new->stagedRevision = null;
        $new->stagedRevisionId = null;

        $new->setPublishedRevision(
            $publishedRevision->newInstance(
                $createdByUserId,
                $createdReason
            )
        );

        return $new;
    }
public function newInstanceIfHasRevision ( string $ createdByUserId , string $ createdReason = Tracking :: UNKNOWN_REASON ) { /** @var ContainerInterface|ContainerAbstract $new */ $ new = parent :: newInstance ( $ createdByUserId , $ createdReason ) ; $ publishedRevision = $ new -> getPublishedRevision ( ) ; if ( empty ( $ publishedRevision ) ) { return null ; } $ new -> lastPublished = new \ DateTime ( ) ; $ new -> revisions = new ArrayCollection ( ) ; $ new -> stagedRevision = null ; $ new -> stagedRevisionId = null ; $ new -> setPublishedRevision ( $ publishedRevision -> newInstance ( $ createdByUserId , $ createdReason ) ) ; return $ new ; }
This is used mainly for site copies to eliminate pages that are not published

@param string $createdByUserId
@param string $createdReason

@return null|ContainerAbstract|ContainerInterface
This is used mainly for site copies to eliminate pages that are not published