public function updateVertex($graph, $vertexId, Document $document, array $options = [], $collection = null)
    {
        if ($graph instanceof Graph) {
            $graph = $graph->getKey();
        }
        $parts = explode('/', $vertexId);
        if (count($parts) === 2) {
            list($collection, $vertexId) = $parts;
        }

        if ($collection === null) {
            $vertexCollections      = $this->getVertexCollections($graph);
            $vertexCollectionsCount = count($vertexCollections);
            if ($vertexCollectionsCount !== 1) {
                throw new ClientException('A collection must be provided.');
            }

            if ($vertexCollectionsCount === 1) {
                $collection = $vertexCollections[0];
            }
        }

        $options = array_merge([self::OPTION_REVISION => false], $options);

        $params = $this->includeOptionsInParams(
            $options, [
                'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC),
                'keepNull'    => true,
                'policy'      => $this->getConnectionOption(ConnectionOptions::OPTION_UPDATE_POLICY)

            ]
        );

        //Include the revision for conditional updates if required
        if ($options[self::OPTION_REVISION] === true) {
            $revision = $document->getRevision();

            if (null !== $revision) {
                $params[ConnectionOptions::OPTION_REVISION] = $revision;
            }
        } elseif ($options[self::OPTION_REVISION]) {
            $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION];
        }

        $url    = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]);
        $url    = UrlHelper::appendParamsUrl($url, $params);
        $result = $this->getConnection()->patch($url, $this->json_encode_wrapper($document->getAll()));
        $json   = $result->getJson();
        $vertex = $json['vertex'];
        $document->setRevision($vertex[Vertex::ENTRY_REV]);

        return true;
    }
public function updateVertex($graph, $vertexId, Document $document, array $options = [], $collection = null)
    {
        if ($graph instanceof Graph) {
            $graph = $graph->getKey();
        }
        $parts = explode('/', $vertexId);
        if (count($parts) === 2) {
            list($collection, $vertexId) = $parts;
        }

        if ($collection === null) {
            $vertexCollections      = $this->getVertexCollections($graph);
            $vertexCollectionsCount = count($vertexCollections);
            if ($vertexCollectionsCount !== 1) {
                throw new ClientException('A collection must be provided.');
            }

            if ($vertexCollectionsCount === 1) {
                $collection = $vertexCollections[0];
            }
        }

        $options = array_merge([self::OPTION_REVISION => false], $options);

        $params = $this->includeOptionsInParams(
            $options, [
                'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC),
                'keepNull'    => true,
                'policy'      => $this->getConnectionOption(ConnectionOptions::OPTION_UPDATE_POLICY)

            ]
        );

        //Include the revision for conditional updates if required
        if ($options[self::OPTION_REVISION] === true) {
            $revision = $document->getRevision();

            if (null !== $revision) {
                $params[ConnectionOptions::OPTION_REVISION] = $revision;
            }
        } elseif ($options[self::OPTION_REVISION]) {
            $params[ConnectionOptions::OPTION_REVISION] = $options[self::OPTION_REVISION];
        }

        $url    = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_VERTEX, $collection, $vertexId]);
        $url    = UrlHelper::appendParamsUrl($url, $params);
        $result = $this->getConnection()->patch($url, $this->json_encode_wrapper($document->getAll()));
        $json   = $result->getJson();
        $vertex = $json['vertex'];
        $document->setRevision($vertex[Vertex::ENTRY_REV]);

        return true;
    }
public function updateVertex ( $ graph , $ vertexId , Document $ document , array $ options = [ ] , $ collection = null ) { if ( $ graph instanceof Graph ) { $ graph = $ graph -> getKey ( ) ; } $ parts = explode ( '/' , $ vertexId ) ; if ( count ( $ parts ) === 2 ) { list ( $ collection , $ vertexId ) = $ parts ; } if ( $ collection === null ) { $ vertexCollections = $ this -> getVertexCollections ( $ graph ) ; $ vertexCollectionsCount = count ( $ vertexCollections ) ; if ( $ vertexCollectionsCount !== 1 ) { throw new ClientException ( 'A collection must be provided.' ) ; } if ( $ vertexCollectionsCount === 1 ) { $ collection = $ vertexCollections [ 0 ] ; } } $ options = array_merge ( [ self :: OPTION_REVISION => false ] , $ options ) ; $ params = $ this -> includeOptionsInParams ( $ options , [ 'waitForSync' => $ this -> getConnectionOption ( ConnectionOptions :: OPTION_WAIT_SYNC ) , 'keepNull' => true , 'policy' => $ this -> getConnectionOption ( ConnectionOptions :: OPTION_UPDATE_POLICY ) ] ) ; //Include the revision for conditional updates if required if ( $ options [ self :: OPTION_REVISION ] === true ) { $ revision = $ document -> getRevision ( ) ; if ( null !== $ revision ) { $ params [ ConnectionOptions :: OPTION_REVISION ] = $ revision ; } } elseif ( $ options [ self :: OPTION_REVISION ] ) { $ params [ ConnectionOptions :: OPTION_REVISION ] = $ options [ self :: OPTION_REVISION ] ; } $ url = UrlHelper :: buildUrl ( Urls :: URL_GRAPH , [ $ graph , Urls :: URLPART_VERTEX , $ collection , $ vertexId ] ) ; $ url = UrlHelper :: appendParamsUrl ( $ url , $ params ) ; $ result = $ this -> getConnection ( ) -> patch ( $ url , $ this -> json_encode_wrapper ( $ document -> getAll ( ) ) ) ; $ json = $ result -> getJson ( ) ; $ vertex = $ json [ 'vertex' ] ; $ document -> setRevision ( $ vertex [ Vertex :: ENTRY_REV ] ) ; return true ; }
Update an existing vertex in a graph, identified by graph name and vertex id

This will update the vertex on the server

This will throw if the vertex cannot be updated

If policy is set to error (locally or globally through the ConnectionOptions)
and the passed vertex-document has a _rev value set, the database will check
that the revision of the to-be-replaced document is the same as the one given.<br><br>

@throws Exception

@param mixed    $graph      - graph name as a string or instance of Graph
@param mixed    $vertexId   - the vertex id as string or number
@param Document $document   - the patch vertex-document which contains the attributes and values to be updated
@param mixed    $options    optional, an array of options (see below)
<p>
<li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
<li><b>keepNull</b> - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)</li>
<li><b>waitForSync</b> - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
</p>
@param string   $collection - if one uses a graph with more than one vertex collection one must provide the collection

@return bool - always true, will throw if there is an error
@since 1.2
Update an existing vertex in a graph identified by graph name and vertex id