Returns an object in the collection. If the revision isn't provided, the
latest revision of the object will be returned.
@param string $id
@param int $revision
@return object|null
176296
private function _getObject($id, $revision = null)
    {
        if ($revision === null) {
            $select = Statement::get(
                'GET_CURRENT_OBJECT',
                [
                    '@collection' => $this->_name,
                    '@id' => $this->_connector->quote($id)
                ]
            );
            $record = $this->_connector->query($select)->fetch();
            if ($record) {
                return json_decode($record['obj']);
            }
        }
        return null;
    }
1076105
public function getMediaType($revision = null)
	{
		// Without revision, use current info
		if (!isset($revision)) {
			return $this->info['mediatype'];
		}

		// Obtain the properties of the revision
		if (($info = $this->getRevision($revision)) === null) {
			return null;
		}

		return $info['mediatype'];
	}
1340073
public function restore(Revision $revision) {
        $resourceId = $revision->getResourceId();
        $data = $this->getStorage()->getData($revision);

        $resource = new \core_kernel_classes_Resource($resourceId);
        $originFilesystemMap = CloneHelper::getPropertyStorageMap($resource->getRdfTriples());
        DeleteHelper::deepDelete($resource);

        foreach (CloneHelper::deepCloneTriples($data, $originFilesystemMap) as $triple) {
            ModelManager::getModel()->getRdfInterface()->add($triple);
        }

        return true;
    }
473134
public function find($id, int $lockMode = LockMode::NONE, ?int $lockVersion = null) : ?object
    {
        if ($id === null) {
            return null;
        }

        /* TODO: What if the ID object has a field with the same name as the
         * class' mapped identifier field name?
         */
        if (is_array($id)) {
            [$identifierFieldName] = $this->class->getIdentifierFieldNames();

            if (isset($id[$identifierFieldName])) {
                $id = $id[$identifierFieldName];
            }
        }

        // Check identity map first
        $document = $this->uow->tryGetById($id, $this->class);
        if ($document) {
            if ($lockMode !== LockMode::NONE) {
                $this->dm->lock($document, $lockMode, $lockVersion);
            }

            return $document; // Hit!
        }

        $criteria = ['_id' => $id];

        if ($lockMode === LockMode::NONE) {
            return $this->getDocumentPersister()->load($criteria);
        }

        if ($lockMode === LockMode::OPTIMISTIC) {
            if (! $this->class->isVersioned) {
                throw LockException::notVersioned($this->documentName);
            }

            $document = $this->getDocumentPersister()->load($criteria);
            if ($document) {
                $this->uow->lock($document, $lockMode, $lockVersion);
            }

            return $document;
        }

        return $this->getDocumentPersister()->load($criteria, null, [], $lockMode);
    }
127378
def restore_revision(id, revision_number)
      revision_record = revision(id, revision_number)
      return revision_record.restore if revision_record
    end
116643
public function getCollectionByContentAction($type, $uid, $start, $count)
    {
        $content = $this->findOneByTypeAndUid($type, $uid);
        $this->granted('VIEW', $content);

        $revisions = $this->getEntityManager()
                ->getRepository('BackBee\ClassContent\Revision')
                ->getRevisions($content, [Revision::STATE_COMMITTED], $start, $count);

        $result = [];
        foreach ($revisions as $revision) {
            $result[] = $revision->jsonSerialize(Revision::JSON_REVISION_FORMAT);
        }

        $response = $this->createJsonResponse();
        $response->setData($result);

        if ($revisions instanceof Paginator) {
            $response->headers->set('Content-Range', sprintf('%d-%d/%d', $start, $start +
                            count($result) - 1, count($revisions)));
        }

        return $response;
    }
1280205
public function getById($id)
    {
        $record = NavigationRecord::findOne(['id' => $id]);

        if ($record) {
            return new NavigationModel($record->getAttributes());
        }

        return null;
    }
957824
public function revert(&$entity, $revision)
    {
        /** @var ClassMetadataInfo $meta */
        $meta = $this->getClassMetadata(get_class($entity));

        $data = $this->getRevisionData($entity, ['revision_id = :revisionId'], ['revisionId' => $revision], 1);

        /** @var \ReflectionProperty[] $revisedProperties */
        $revisedProperties = $this->annotationReader->getRevisedProperties($entity);

        $exception = null;
        foreach ($revisedProperties as $field => $property) {
            if (! key_exists($field, $revisedProperties)) {
                continue;
            }

            if (isset($meta->fieldMappings[$field])) {
                $columnName = $meta->fieldMappings[$field]['columnName'];
            } elseif (isset($meta->associationMappings[$field])) {
                $columnName = $meta->associationMappings[$field]['joinColumns'][0]['name'];
            } else {
                throw new \Exception('Cannot find column name for' . $field);
            }

            $value = $data[$columnName];

            $property = $meta->getReflectionProperty($field);
            $property->setValue($entity, $value);

            if ($field == 'deletedAt' && $value !== null) {
                $exception = new DeletedException('Entity is deleted in this revision');
            }
        }

        if ($exception) {
            $exception->setEntity($entity);
            throw $exception;
        }

        return $entity;
    }
556622
public function version($versionId, $reset = false)
    {
        $versions = $this->versions($reset);
        if (empty($versions[$versionId])) {
            return null;
        }

        return $versions[$versionId];
    }
1224401
private function getRevision($document)
    {
        $revision = null;

        if ($document instanceof Document) {
            $revision = $document->getRevision();
        }

        return $revision;
    }
586813
public function get($id, $default = null)
    {
        $query = $this->model->newQuery();

        $this->publish('getting', $query);

        if (!$model = $query->find($id)) {
            return $default;
        }

        $this->publish('got', $model);

        return $model;
    }
345768
public function restore( Revision $revision ) {
		$params = [
			'type' => 'revision',
			'show' => 'content',
			// Note: pre 1.24 this is a delete token, post it is csrf
			'token' => $this->api->getToken( 'delete' ),
			'ids' => $revision->getId(),
		];

		$this->api->postRequest( new SimpleRequest(
			'revisiondelete',
			$params
		) );

		return true;
	}
521470
private function find($id): ?Model
    {
        try {
            return $this->repository->findOrFail($id);
        } catch (ModelNotFoundException $exception) {
            return null;
        }
    }
398058
public function getAction(Revision $revision)
    {
        $this->granted('VIEW', $revision->getContent());

        $response = $this->createJsonResponse();
        $response->setData($revision->jsonSerialize(Revision::JSON_REVISION_FORMAT));

        return $response;
    }
934458
public function getLastUpdate($id = null)
    {
        if ($id) {
            $result = $this->getEntityManager()->createQuery('
                SELECT
                    i.date_update
                FROM
                    AnimeDbCatalogBundle:Item i
                WHERE
                    i.id = :id'
            )
                ->setParameter(':id', $id)
                ->getOneOrNullResult();
        } else {
            $result = $this->getEntityManager()->createQuery('
                SELECT
                    i.date_update
                FROM
                    AnimeDbCatalogBundle:Item i
                ORDER BY
                    i.date_update DESC'
            )
                ->setMaxResults(1)
                ->getOneOrNullResult();
        }

        return $result ? $result['date_update'] : null;
    }
743609
public function getWidth($revision = null)
	{
		// Without revision, use current info
		if (!isset($revision)) {
			return (int)$this->info['width'];
		}

		// Obtain the properties of the revision
		if (($info = $this->getRevision($revision)) === null) {
			return -1;
		}

		return (int)$info['width'];
	}
325450
public function getRevision() : ?string 
    {
        if ( ! $this->hasRevision()) {
            $this->setRevision($this->getDefaultRevision());
        }
        return $this->revision;
    }