public function getAllDrafts(TokenInterface $token)
    {
        $owner = UserSecurityIdentity::fromToken($token);
        $states = [Revision::STATE_ADDED, Revision::STATE_MODIFIED];

        $result = [];

        try {
            $result = $this->findBy([
                '_owner' => $owner,
                '_state' => $states,
            ]);
        } catch (ConversionException $e) {
            $result = [];
            foreach ($this->getAllDraftsUids($owner, $states) as $data) {
                try {
                    $result[] = $this->find($data['_uid']);
                } catch (ConversionException $e) {
                    $this->_em->getConnection()->executeUpdate(
                        'DELETE FROM revision WHERE uid = :uid',
                        ['uid' => $data['_uid']]
                    );
                }
            }
        } catch (MappingException $e) {
            $result = [];
            foreach ($this->getAllDraftsUids($owner, $states) as $data) {
                $draft = $this->find($data['_uid']);
                if (null !== $draft->getContent()) {
                    $result[] = $draft;
                } else {
                    $this->_em->getConnection()->executeUpdate(
                        'DELETE FROM revision WHERE uid = :uid',
                        ['uid' => $data['_uid']]
                    );
                }
            }
        }

        return $result;
    }
public function getAllDrafts(TokenInterface $token)
    {
        $owner = UserSecurityIdentity::fromToken($token);
        $states = [Revision::STATE_ADDED, Revision::STATE_MODIFIED];

        $result = [];

        try {
            $result = $this->findBy([
                '_owner' => $owner,
                '_state' => $states,
            ]);
        } catch (ConversionException $e) {
            $result = [];
            foreach ($this->getAllDraftsUids($owner, $states) as $data) {
                try {
                    $result[] = $this->find($data['_uid']);
                } catch (ConversionException $e) {
                    $this->_em->getConnection()->executeUpdate(
                        'DELETE FROM revision WHERE uid = :uid',
                        ['uid' => $data['_uid']]
                    );
                }
            }
        } catch (MappingException $e) {
            $result = [];
            foreach ($this->getAllDraftsUids($owner, $states) as $data) {
                $draft = $this->find($data['_uid']);
                if (null !== $draft->getContent()) {
                    $result[] = $draft;
                } else {
                    $this->_em->getConnection()->executeUpdate(
                        'DELETE FROM revision WHERE uid = :uid',
                        ['uid' => $data['_uid']]
                    );
                }
            }
        }

        return $result;
    }
public function getAllDrafts ( TokenInterface $ token ) { $ owner = UserSecurityIdentity :: fromToken ( $ token ) ; $ states = [ Revision :: STATE_ADDED , Revision :: STATE_MODIFIED ] ; $ result = [ ] ; try { $ result = $ this -> findBy ( [ '_owner' => $ owner , '_state' => $ states , ] ) ; } catch ( ConversionException $ e ) { $ result = [ ] ; foreach ( $ this -> getAllDraftsUids ( $ owner , $ states ) as $ data ) { try { $ result [ ] = $ this -> find ( $ data [ '_uid' ] ) ; } catch ( ConversionException $ e ) { $ this -> _em -> getConnection ( ) -> executeUpdate ( 'DELETE FROM revision WHERE uid = :uid' , [ 'uid' => $ data [ '_uid' ] ] ) ; } } } catch ( MappingException $ e ) { $ result = [ ] ; foreach ( $ this -> getAllDraftsUids ( $ owner , $ states ) as $ data ) { $ draft = $ this -> find ( $ data [ '_uid' ] ) ; if ( null !== $ draft -> getContent ( ) ) { $ result [ ] = $ draft ; } else { $ this -> _em -> getConnection ( ) -> executeUpdate ( 'DELETE FROM revision WHERE uid = :uid' , [ 'uid' => $ data [ '_uid' ] ] ) ; } } } return $ result ; }
Returns all current drafts for authenticated user.

@param TokenInterface $token

@return array
Returns all current drafts for authenticated user .