public function getLastSavedDraftRevision()
    {
        if (!empty($this->lastSavedDraft)) {
            return $this->lastSavedDraft;
        }

        $published = $this->publishedRevision;
        $staged = $this->stagedRevision;

        $arrayCollection = $this->revisions->toArray();

        /** @var \Rcm\Entity\Revision $revision */
        $revision = end($arrayCollection);

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

        $found = false;

        while (!$found) {
            if (empty($revision)) {
                break;
            } elseif (!empty($published)
                && $published->getRevisionId() == $revision->getRevisionId()
            ) {
                $found = false;
            } elseif (!empty($staged)
                && $staged->getRevisionId() == $revision->getRevisionId()
            ) {
                $found = false;
            } elseif ($revision->wasPublished()) {
                $found = false;
            } else {
                $found = true;
            }

            if (!$found) {
                $revision = prev($arrayCollection);
            }
        }

        return $this->lastSavedDraft = $revision;
    }
public function getLastSavedDraftRevision()
    {
        if (!empty($this->lastSavedDraft)) {
            return $this->lastSavedDraft;
        }

        $published = $this->publishedRevision;
        $staged = $this->stagedRevision;

        $arrayCollection = $this->revisions->toArray();

        /** @var \Rcm\Entity\Revision $revision */
        $revision = end($arrayCollection);

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

        $found = false;

        while (!$found) {
            if (empty($revision)) {
                break;
            } elseif (!empty($published)
                && $published->getRevisionId() == $revision->getRevisionId()
            ) {
                $found = false;
            } elseif (!empty($staged)
                && $staged->getRevisionId() == $revision->getRevisionId()
            ) {
                $found = false;
            } elseif ($revision->wasPublished()) {
                $found = false;
            } else {
                $found = true;
            }

            if (!$found) {
                $revision = prev($arrayCollection);
            }
        }

        return $this->lastSavedDraft = $revision;
    }
public function getLastSavedDraftRevision ( ) { if ( ! empty ( $ this -> lastSavedDraft ) ) { return $ this -> lastSavedDraft ; } $ published = $ this -> publishedRevision ; $ staged = $ this -> stagedRevision ; $ arrayCollection = $ this -> revisions -> toArray ( ) ; /** @var \Rcm\Entity\Revision $revision */ $ revision = end ( $ arrayCollection ) ; if ( empty ( $ revision ) ) { return null ; } $ found = false ; while ( ! $ found ) { if ( empty ( $ revision ) ) { break ; } elseif ( ! empty ( $ published ) && $ published -> getRevisionId ( ) == $ revision -> getRevisionId ( ) ) { $ found = false ; } elseif ( ! empty ( $ staged ) && $ staged -> getRevisionId ( ) == $ revision -> getRevisionId ( ) ) { $ found = false ; } elseif ( $ revision -> wasPublished ( ) ) { $ found = false ; } else { $ found = true ; } if ( ! $ found ) { $ revision = prev ( $ arrayCollection ) ; } } return $ this -> lastSavedDraft = $ revision ; }
Return the last draft saved.

@return Revision
Return the last draft saved .