@param string     $id
@param int        $version
@param string     $name
@param array|null $labels
@param string     $role
@param string     $availability

@return mixed

@throws \Exception
546047
public function update(string $id,
                           int $version,
                           string $name,
                           array $labels = null,
                           string $role = null,
                           string $availability = null)
    {
        $url = self::BASE_URL.'/'.$id.'/update?'.http_build_query(['version' => $version]);

        $request = [
            'Name' => $name,
            'Labels' => $labels,
            'Role' => $role,
            'Availability' => $availability,
        ];

        return $this->curl->post($url, json_encode($request));
    }
631186
protected function fetchVersionValue(VersionFieldMetadata $versionProperty, array $id)
    {
        $versionedClass = $versionProperty->getDeclaringClass();
        $tableName      = $versionedClass->table->getQuotedQualifiedName($this->platform);
        $columnName     = $this->platform->quoteIdentifier($versionProperty->getColumnName());
        $identifier     = array_map(
            function ($columnName) {
                return $this->platform->quoteIdentifier($columnName);
            },
            array_keys($versionedClass->getIdentifierColumns($this->em))
        );

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

        $flattenedId = $this->em->getIdentifierFlattener()->flattenIdentifier($versionedClass, $id);
        $versionType = $versionProperty->getType();

        $value = $this->conn->fetchColumn(
            $sql,
            array_values($flattenedId),
            0,
            $this->extractIdentifierTypes($id, $versionedClass)
        );

        return $versionType->convertToPHPValue($value, $this->platform);
    }
293033
public function fetch($identifier, $version=null)
    {
        $portableElements = $this->getAllVersions($identifier);

        // No version, return latest version
        if (is_null($version)) {
            $this->krsortByVersion($portableElements);
            return $this->getModel()->createDataObject(reset($portableElements));
        }

        // Version is set, return associated record
        if (isset($portableElements[$version])) {
            return $this->getModel()->createDataObject($portableElements[$version]);
        }

        // Version is set, no record found
        throw new PortableElementNotFoundException(
            $this->getModel()->getId() . ' with identifier ' . $identifier. ' found, '
            . 'but version "' . $version . '" does not exist.'
        );
    }
371334
public function getPortableElementByIdentifier($type, $identifier, $version=null)
    {
        $model = $this->getPortableModelRegistry()->getModel($type);
        $registry = $model->getRegistry();

        if($registry->has($identifier, $version)){
            return $registry->fetch($identifier, $version);
        }
        return null;
    }
1271207
public function load($id, Persistence $from_persistence = null)
    {
        if (!$from_persistence) {
            $from_persistence = $this->persistence;
        }

        if (!$from_persistence) {
            throw new Exception(['Model is not associated with any database']);
        }

        if ($this->loaded()) {
            $this->unload();
        }

        if ($this->hook('beforeLoad', [$id]) === false) {
            return $this;
        }

        $this->data = $from_persistence->load($this, $id);
        if (null === $this->id) {
            $this->id = $id;
        }

        $ret = $this->hook('afterLoad');
        if ($ret === false) {
            return $this->unload();
        } elseif (is_object($ret)) {
            return $ret;
        }

        return $this;
    }
800950
public function update(string $id,
                           int $version,
                           string $name,
                           string $data,
                           array $labels = [],
                           array $templating = [])
    {
        $data = array_filter([
            'Name' => $name,
            'Labels' => $labels,
            'Data' => $data,
            'Templating' => $templating,
        ]);

        $url = $this->url.'/'.$id.'/update?'.http_build_query(['version' => $version]);

        return $this->curl->post($url, json_encode($data));
    }
123872
protected function need_update($name, $version){
        return !isset($this->option[$name]) || !$this->option[$name] || version_compare($this->option[$name], $version, '<');
    }
541660
protected function createUuid($version, $namespace = null, $name = null)
    {
        switch ((int) $version) {
            case 1:
                $uuid = Uuid::uuid1();
                break;
            case 4:
                $uuid = Uuid::uuid4();
                break;
            case 3:
            case 5:
                $ns = $this->validateNamespace($namespace);
                if (empty($name)) {
                    throw new Exception('The name argument is required for version 3 or 5 UUIDs');
                }
                if ($version == 3) {
                    $uuid = Uuid::uuid3($ns, $name);
                } else {
                    $uuid = Uuid::uuid5($ns, $name);
                }
                break;
            default:
                throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".');
        }

        return $uuid;
    }
443744
public function tryLoad($id)
    {
        if (is_null($id)) {
            throw $this->exception('Record ID must be specified, otherwise use loadAny()');
        }

        return $this->_load($id, true);
    }
1178668
public function getVersion(string $id, int $version = 1): array
    {
        $this->setFile($id);
        $id = Check::name(pathinfo($id, PATHINFO_FILENAME));
        try {
            $fileName = str_replace("{$id}.json", "version/{$id}#{$version}.json", $this->file);
            if (file_exists($fileName))
                return array_merge(["id" => $id], json_decode(file_get_contents($fileName), true));
        } catch (\Exception $e) {
            return [];
        }
        return [];
    }
95700
public function versionPickerAction($id, $current, $published = 0)
    {
        if ($this->getDoctrine()->getManager()->getFilters()->isEnabled('draftversion')) {
            $this->getDoctrine()->getManager()->getFilters()->disable('draftversion');
        }

        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');
        $block   = $manager->find($id);

        $logEntries = $manager->getRootVersions($block);

        return $this->render('OpiferContentBundle:Editor:version_picker.html.twig', ['logentries' => $logEntries, 'current' => $current, 'published' => $published]);
    }
1237113
public function tryLoad($id)
    {
        if (!$this->persistence) {
            throw new Exception(['Model is not associated with any database']);
        }

        if (!$this->persistence->hasMethod('tryLoad')) {
            throw new Exception('Persistence does not support tryLoad()');
        }

        if ($this->loaded()) {
            $this->unload();
        }

        $this->data = $this->persistence->tryLoad($this, $id);
        if ($this->data) {
            $this->id = $id;

            $ret = $this->hook('afterLoad');
            if ($ret === false) {
                return $this->unload();
            } elseif (is_object($ret)) {
                return $ret;
            }
        } else {
            $this->unload();
        }

        return $this;
    }
424699
public function collection(
        ResourceManager $resourceManager,
        ApiRequest $request,
        int $version,
        string $resource
    )
    {
        $resourceManager->version($version);

        /** @var HandlesCollectionRequest $handler */
        $handler = $this->initializeHandler($resourceManager, $resource, $request, HandlesCollectionRequest::class);

        $parameters = $request->asParameters();

        $repository = $this->initializeRepository($resourceManager, $resource, $parameters);

        $result = $handler->index($repository, $parameters);

        $document = $this->makeDocumentFromCollection($resourceManager, $resource, $result, $parameters, $handler);

        return $this->respond($document);
    }
346296
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
    {
        // Check identity map first
        if ($entity = $this->xem->getUnitOfWork()->tryGetById($id, $this->class->rootXmlEntityName)) {
            if ($lockMode != LockMode::NONE) {
                $this->xem->lock($entity, $lockMode, $lockVersion);
            }

            return $entity; // Hit!
        }

        if ($lockMode == LockMode::NONE) {
            return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id);
        } else if ($lockMode == LockMode::OPTIMISTIC) {
            if (!$this->class->isVersioned) {
                throw OptimisticLockException::notVersioned($this->entityName);
            }
            $entity = $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id);

            $this->xem->getUnitOfWork()->lock($entity, $lockMode, $lockVersion);

            return $entity;
        } else {
            if (!$this->xem->getConnection()->isTransactionActive()) {
                throw TransactionRequiredException::transactionRequired();
            }

            return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id, null, null, array(), $lockMode);
        }
    }
1186420
static function fetch( $roleID, $version = 0 )
    {
        if ( $version != 0 )
        {
            return eZPersistentObject::fetchObject( eZRole::definition(),
                                                    null, array( 'version' => $version ), true );
        }
        return eZPersistentObject::fetchObject( eZRole::definition(),
                                                null, array('id' => $roleID ), true );
    }
377968
public function deleteVersionAction(Request $request, $id, $version)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);
        $mediaManager = $this->getMediaManager();
        $media = $mediaManager->getById($id, $locale);

        if ($media->getVersion() === (int) $version) {
            throw new BadRequestHttpException('Can\'t delete active version of a media.');
        }

        $currentFileVersion = null;

        /** @var Media $mediaEntity */
        foreach ($media->getFile()->getFileVersions() as $fileVersion) {
            if ($fileVersion->getVersion() === (int) $version) {
                $currentFileVersion = $fileVersion;
                break;
            }
        }

        if (!$currentFileVersion) {
            throw new NotFoundHttpException(sprintf(
                'Version "%s" for Media "%s"',
                $version,
                $id
            ));
        }

        $entityManager = $this->get('doctrine.orm.entity_manager');
        $entityManager->remove($currentFileVersion);
        $entityManager->flush();
        // After successfully delete in the database remove file from storage
        $this->get('sulu_media.storage')->remove($currentFileVersion->getStorageOptions());

        return new Response('', 204);
    }
627852
public function get($id)
    {
        try {
            $em = $this->entityManager->getDoctrineEntityManager();
            $accessEntity = $em->getRepository($this->getEntityClass())->findOneBy(array(
                'id' => $id,
            ));
            
            if ($accessEntity !== null) {
                return $accessEntity;
            }
            
            return false;
        } catch (\Exception $e) {
            throw new Exception('Cannot load the entity from the database for the given id "' . $id . '".', 0, $e);
        }
    }