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

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

            if ($edgeCollectionsCount === 1) {
                $collection = $edgeCollections[0];
            }
        }

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

        $params = $this->includeOptionsInParams(
            $options, [
                'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC),
                'silent'      => false,
                'ignoreRevs'  => true,
                'policy'      => $this->getConnectionOption(ConnectionOptions::OPTION_REPLACE_POLICY),
            ]
        );

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

            if (null !== $revision) {
                $params['ignoreRevs'] = false;
                $headers['if-match']  = '"' . $revision . '"';
            }
        } elseif ($options[self::OPTION_REVISION]) {
            $revision             = $options[self::OPTION_REVISION];
            $params['ignoreRevs'] = false;
            $headers['if-match']  = '"' . $revision . '"';
        }

        $data = $document->getAllForInsertUpdate();
        if (null !== $label) {
            $document->set('$label', $label);
        }

        $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]);
        $url = UrlHelper::appendParamsUrl($url, $params);

        $response = $this->getConnection()->put($url, $this->json_encode_wrapper($data), $headers);

        $jsonArray = $response->getJson();
        $edge      = $jsonArray['edge'];

        $document->setInternalId($edge[Edge::ENTRY_ID]);
        $document->setRevision($edge[Edge::ENTRY_REV]);

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

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

            if ($edgeCollectionsCount === 1) {
                $collection = $edgeCollections[0];
            }
        }

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

        $params = $this->includeOptionsInParams(
            $options, [
                'waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC),
                'silent'      => false,
                'ignoreRevs'  => true,
                'policy'      => $this->getConnectionOption(ConnectionOptions::OPTION_REPLACE_POLICY),
            ]
        );

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

            if (null !== $revision) {
                $params['ignoreRevs'] = false;
                $headers['if-match']  = '"' . $revision . '"';
            }
        } elseif ($options[self::OPTION_REVISION]) {
            $revision             = $options[self::OPTION_REVISION];
            $params['ignoreRevs'] = false;
            $headers['if-match']  = '"' . $revision . '"';
        }

        $data = $document->getAllForInsertUpdate();
        if (null !== $label) {
            $document->set('$label', $label);
        }

        $url = UrlHelper::buildUrl(Urls::URL_GRAPH, [$graph, Urls::URLPART_EDGE, $collection, $edgeId]);
        $url = UrlHelper::appendParamsUrl($url, $params);

        $response = $this->getConnection()->put($url, $this->json_encode_wrapper($data), $headers);

        $jsonArray = $response->getJson();
        $edge      = $jsonArray['edge'];

        $document->setInternalId($edge[Edge::ENTRY_ID]);
        $document->setRevision($edge[Edge::ENTRY_REV]);

        return true;
    }
public function replaceEdge ( $ graph , $ edgeId , $ label , Edge $ document , array $ options = [ ] , $ collection = null ) { if ( $ graph instanceof Graph ) { $ graph = $ graph -> getKey ( ) ; } $ parts = explode ( '/' , $ edgeId ) ; if ( count ( $ parts ) === 2 ) { list ( $ collection , $ edgeId ) = $ parts ; } if ( $ collection === null ) { $ edgeCollections = $ this -> getEdgeCollections ( $ graph ) ; $ edgeCollectionsCount = count ( $ edgeCollections ) ; if ( $ edgeCollectionsCount !== 1 ) { throw new ClientException ( 'A collection must be provided.' ) ; } if ( $ edgeCollectionsCount === 1 ) { $ collection = $ edgeCollections [ 0 ] ; } } $ options = array_merge ( [ self :: OPTION_REVISION => false ] , $ options ) ; $ params = $ this -> includeOptionsInParams ( $ options , [ 'waitForSync' => $ this -> getConnectionOption ( ConnectionOptions :: OPTION_WAIT_SYNC ) , 'silent' => false , 'ignoreRevs' => true , 'policy' => $ this -> getConnectionOption ( ConnectionOptions :: OPTION_REPLACE_POLICY ) , ] ) ; //Include the revision for conditional updates if required $ headers = [ ] ; if ( $ options [ self :: OPTION_REVISION ] === true ) { $ revision = $ document -> getRevision ( ) ; if ( null !== $ revision ) { $ params [ 'ignoreRevs' ] = false ; $ headers [ 'if-match' ] = '"' . $ revision . '"' ; } } elseif ( $ options [ self :: OPTION_REVISION ] ) { $ revision = $ options [ self :: OPTION_REVISION ] ; $ params [ 'ignoreRevs' ] = false ; $ headers [ 'if-match' ] = '"' . $ revision . '"' ; } $ data = $ document -> getAllForInsertUpdate ( ) ; if ( null !== $ label ) { $ document -> set ( '$label' , $ label ) ; } $ url = UrlHelper :: buildUrl ( Urls :: URL_GRAPH , [ $ graph , Urls :: URLPART_EDGE , $ collection , $ edgeId ] ) ; $ url = UrlHelper :: appendParamsUrl ( $ url , $ params ) ; $ response = $ this -> getConnection ( ) -> put ( $ url , $ this -> json_encode_wrapper ( $ data ) , $ headers ) ; $ jsonArray = $ response -> getJson ( ) ; $ edge = $ jsonArray [ 'edge' ] ; $ document -> setInternalId ( $ edge [ Edge :: ENTRY_ID ] ) ; $ document -> setRevision ( $ edge [ Edge :: ENTRY_REV ] ) ; return true ; }
Replace an existing edge in a graph, identified graph name and edge id

This will replace the edge on the server

This will throw if the edge cannot be Replaced

If policy is set to error (locally or globally through the ConnectionOptions)
and the passed document has a _rev value set, the database will check
that the revision of the to-be-replaced edge 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  $edgeId     - edge id as string or number
@param mixed  $label      - label for the edge or ''
@param Edge   $document   - edge document to be updated
@param mixed  $options    optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
<p>
<li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
<li><b>waitForSync</b> - can be used to force synchronisation of the document replacement 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
Replace an existing edge in a graph identified graph name and edge id