Retrieves a specified version for the current entity

@param int $versionId The version number to retrieve
@param bool $reset If true, will re-retrieve the related version collection
@return \Cake\ORM\Entity|null
556622
public function version($versionId, $reset = false)
    {
        $versions = $this->versions($reset);
        if (empty($versions[$versionId])) {
            return null;
        }

        return $versions[$versionId];
    }
704547
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerShedulesVersionQuery::create()
            ->filterByDealerShedules($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
886382
def get_version_by_version_id(version_id):
    
    for ver in registry.version_info:
        if ver.version_id == version_id:
            return ver.id

    return None
521767
public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT)
    {
        try {
            return $this->innerGateway->listVersionsForUser($userId, $status);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
345160
public function reload($resetRelations = false) {   // TODO: implement and set default=TRUE
        if (!$this->isPersistent()) throw new IllegalStateException('Cannot reload non-persistent '.get_class($this));

        // TODO: This method cannot yet handle composite primary keys.

        $db     = $this->db();
        $dao    = $this->dao();
        $entity = $dao->getEntityMapping();
        $table  = $entity->getTableName();

        // collect identity infos
        $identity = $entity->getIdentity();
        $idColumn = $identity->getColumn();
        $idName   = $identity->getName();
        $idValue  = $identity->convertToDBValue($this->$idName, $db);

        // create and execute SQL
        $sql = 'select *
                   from '.$table.'
                   where '.$idColumn.' = '.$idValue;
        $row = $db->query($sql)->fetchRow();
        if ($row === null) throw new ConcurrentModificationException('Error reloading '.get_class($this).' ('.$this->getObjectId().'), record not found');

        // apply record values
        return $this->populate($row);
    }
76651
public function get($version = null, $up = true)
    {
        $currentVersion = $this->schemaTable->getCurrentVersion();
        if (null !== $version && false === $up && (int) $version > (int) $currentVersion) {
            return null;
        }

        $files = $this->getFiles($up);

        if (!$this->fileVersionExists($version, $this->getFiles($up))) {
            return null;
        }

        $migrationFiles = array();
        foreach ($files as $file) {
            $filenameParser = new FileNameParser($file->getFileName());
            $isMigrated = in_array($filenameParser->getVersion(), $this->schemaTable->getVersions());
            $migrationFile = new MigrationFile($filenameParser->getMigrationName(), $file->getRealpath(),
                $filenameParser->getVersion(), $filenameParser->getMigrationClassName(), $isMigrated);

            if (false === $this->statusIntention) {
                if ($up && $isMigrated || !$up && !$isMigrated) {
                    continue;
                }
                if ($version == $migrationFile->getVersion()) {
                    $migrationFiles[] = $migrationFile;
                    break;
                }
            }
            $migrationFiles[] = $migrationFile;
        }

        return $migrationFiles;
    }
931656
protected function getVersion($version)
    {
        if (!$this->{$version.'Version'}) {
            $revisioned = get_class($this->revisioned);

            $revision = new $revisioned();
            $revision->setRawAttributes($this->{$version});

            $this->{$version.'Version'} = $revision;
        }

        return $this->{$version.'Version'};
    }
1003158
public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT)
    {
        $query = $this->queryBuilder->createVersionInfoFindQuery();
        $query->where(
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('status', 'ezcontentobject_version'),
                    $query->bindValue($status, null, \PDO::PARAM_INT)
                ),
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('creator_id', 'ezcontentobject_version'),
                    $query->bindValue($userId, null, \PDO::PARAM_INT)
                )
            )
        );

        return $this->listVersionsHelper($query);
    }
721130
public function getVersions(VersionableInterface $resource)
    {
        $query = $this->_em->createQuery(
            'SELECT v FROM ResourceVersion v INDEX BY v.version '.
            'WHERE v.resourceName = ?1 AND v.resourceId = ?2 ORDER BY v.version DESC');
        $query->setParameter(1, get_class($resource));
        $query->setParameter(2, $resource->getResourceId());

        return $query->getResult();
    }
991780
private function rollbackToRevision(Revision $revision) {
        if ($revision == null) {
            return null;
        }

        $current = $revision->revisioned;

        // delete the old revisions for this model if needed
        if($this->getConfigRollbackCleanup()) {
            $revisionsToDelete = $current->revisions()->where('id', '>=', $revision->id)->delete();
        }

        $current->fill($revision->old);
        $current->save();

        // reload the relations
        $current = $current->load('revisions');

        return $current;
    }
405028
public function getCurrentRemoteVersion(Updater $updater)
    {
        /** Switch remote request errors to HttpRequestExceptions */
        set_error_handler(array($updater, 'throwHttpRequestException'));
        $version = get_contents($this->getVersionUrl());
        restore_error_handler();
        if (false === $version) {
            throw new HttpRequestException(sprintf(
                'Request to URL failed: %s', $this->getVersionUrl()
            ));
        }
        if (empty($version)) {
            throw new HttpRequestException(
                'Version request returned empty response.'
            );
        }
        if (!preg_match('%^[a-z0-9]{40}%', $version, $matches)) {
            throw new HttpRequestException(
                'Version request returned incorrectly formatted response.'
            );
        }

        return $matches[0];
    }
711330
protected function fetchVersionValue($versionedClass, array $id)
    {
        $versionField   = $versionedClass->versionField;
        $tableName      = $this->quoteStrategy->getTableName($versionedClass, $this->platform);
        $identifier     = $this->quoteStrategy->getIdentifierColumnNames($versionedClass, $this->platform);
        $columnName     = $this->quoteStrategy->getColumnName($versionField, $versionedClass, $this->platform);

        // FIXME: Order with composite keys might not be correct
        $sql = 'SELECT ' . $columnName
             . ' FROM '  . $tableName
             . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';

        $flatId = $this->identifierFlattener->flattenIdentifier($versionedClass, $id);

        $value = $this->conn->fetchColumn($sql, array_values($flatId));

        return Type::getType($versionedClass->fieldMappings[$versionField]['type'])->convertToPHPValue($value, $this->platform);
    }
967893
public Version getVersion(Jid jid) throws NoResponseException, XMPPErrorException,
                    NotConnectedException, InterruptedException {
        if (!isSupported(jid)) {
            return null;
        }
        return connection().createStanzaCollectorAndSend(new Version(jid)).nextResultOrThrow();
    }
361940
public function get($property = null, $reset = false)
    {
        if (empty($this->data) || $reset === true) {
            $this->makeRequest($this->getUrl(), 'GET');
            $this->data = $this->getResponseBody();
        }
        if ($property !== null) {
            return $this->data->{$property} ?? [];
        }
        return $this->data;
    }
687227
private function getVersion()
    {
        $select = new QueryBuilder();
        $versionRow = $select
            ->query("SELECT value FROM {$this->table} WHERE param = 'migration_version'")
            ->fetchRow();

        if (!isset($versionRow['value'])) die("Error: Please init the Crater Migration");
        return $versionRow['value'];
    }
861566
public function hasVersionMigrated(Version $version)
    {
        $this->createMigrationCollection();

        $record = $this->getCollection()->findOne(['v' => $version->getVersion()]);

        return null !== $record;
    }
495370
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerVersionQuery::create()
            ->filterByDealer($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }