A handler that manages edges

An edge-document handler that fetches edges from the server and persists them on the server. It does so by issuing the appropriate HTTP requests to the server.

package ArangoDBClient
since 1.0
inherited_from \ArangoDBClient\DocumentHandler

 Methods

Construct a new handler

__construct(\ArangoDBClient\Connection $connection) 

Parameters

$connection

\ArangoDBClient\Connection
  • connection to be used

Construct a new handler

__construct(\ArangoDBClient\Connection $connection) 
Inherited

Parameters

$connection

\ArangoDBClient\Connection
  • connection to be used

Intermediate function to call the createFromArray function from the right context

createFromArrayWithContext($data, $options) : \ArangoDBClient\Edge
inherited_from \ArangoDBClient\DocumentHandler::createFromArrayWithContext()

Parameters

$data

$options

Exceptions

\ArangoDBClient\ClientException

Returns

\ArangoDBClient\Edge

Get connected edges for a given vertex

edges(mixed $collection, mixed $vertexHandle, string $direction = 'any', array $options = array()) : array
since 1.0

Parameters

$collection

mixed
  • edge-collection id as string or number

$vertexHandle

mixed
  • the vertex involved

$direction

string
  • optional defaults to 'any'. Other possible Values 'in' & 'out'

$options

array
  • optional, array of options

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false

Exceptions

\ArangoDBClient\Exception

Returns

array- array of connected edges

Get a single document from a collection

get(string $collection, mixed $documentId, array $options = array()) : \ArangoDBClient\Document
Inherited

Alias method for getById()

Parameters

$collection

string
  • collection id as a string or number

$documentId

mixed
  • document identifier

$options

array
  • optional, array of options

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • 'revision' - the documents revision
  • 'ifMatch' - boolean if given revision should match or not

Exceptions

\ArangoDBClient\Exception

Returns

\ArangoDBClient\Document- the document fetched from the server

Get a single document from a collection

getById(string $collection, mixed $documentId, array $options = array()) : \ArangoDBClient\Document
Inherited

This will throw if the document cannot be fetched from the server.

Parameters

$collection

string
  • collection id as a string or number

$documentId

mixed
  • document identifier

$options

array
  • optional, array of options

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • 'ifMatch' - boolean if given revision should match or not
  • 'revision' - The document is returned if it matches/not matches revision.

Exceptions

\ArangoDBClient\Exception

Returns

\ArangoDBClient\Document- the document fetched from the server

Gets information about a single documents from a collection

getHead(string $collection, mixed $documentId, string $revision = null, boolean $ifMatch = null) : array
Inherited

This will throw if the document cannot be fetched from the server

Parameters

$collection

string
  • collection id as a string or number.

$documentId

mixed
  • document identifier.

$revision

string
  • The document is returned if it matches/not matches revision.

$ifMatch

boolean
  • boolean if given revision should match or not.

Exceptions

\ArangoDBClient\Exception

Returns

array- an array containing the complete header including the key httpCode.

Check if a document exists

has(string $collection, mixed $documentId) : boolean
Inherited

This will call self::get() internally and checks if there was an exception thrown which represents an 404 request.

Parameters

$collection

string
  • collection id as a string or number

$documentId

mixed
  • document identifier

Exceptions

\ArangoDBClient\Exception When any other error than a 404 occurs

Returns

boolean

Get connected inbound edges for a given vertex

inEdges(mixed $collection, mixed $vertexHandle) : array

Parameters

$collection

mixed
  • edge-collection id as string or number

$vertexHandle

mixed
  • the vertex involved

Exceptions

\ArangoDBClient\Exception

Returns

array- array of connected edges

insert a document into a collection

insert(mixed $collection, \ArangoDBClient\Document|array $document, array $options = array()) : mixed
Inherited

This will add the document to the collection and return the document's id

This will throw if the document cannot be saved

since 1.0

Parameters

$collection

mixed
  • collection id as string or number

$document

\ArangoDBClient\Documentarray
  • the document to be added, can be passed as a document or an array

$options

array
  • optional, array of options

    Options are :

  • 'createCollection' - create the collection if it does not yet exist.
  • 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.
  • 'overwrite' - if set to true, will turn the insert into a replace operation if a document with the specified key already exists.
  • 'returnNew' - if set to true, then the newly created document will be returned.
  • 'returnOld' - if set to true, then the replaced document will be returned - useful only when using overwrite = true.

Exceptions

\ArangoDBClient\Exception

Returns

mixed- id of document created

Get connected outbound edges for a given vertex

outEdges(mixed $collection, mixed $vertexHandle) : array

Parameters

$collection

mixed
  • edge-collection id as string or number

$vertexHandle

mixed
  • the vertex involved

Exceptions

\ArangoDBClient\Exception

Returns

array- array of connected edges

Remove a document from a collection, identified by the document itself

remove(\ArangoDBClient\Document $document, array $options = array()) : boolean
Inherited

Parameters

$document

\ArangoDBClient\Document
  • document to be removed

$options

array
  • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • 'waitForSync' - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection

Exceptions

\ArangoDBClient\Exception

Returns

boolean- always true, will throw if there is an error

Remove a document from a collection, identified by the collection id and document id

removeById(mixed $collection, mixed $documentId, mixed $revision = null, array $options = array()) : boolean
Inherited

Parameters

$collection

mixed
  • collection id as string or number

$documentId

mixed
  • document id as string or number

$revision

mixed
  • optional revision of the document to be deleted

$options

array
  • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • 'waitForSync' - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection

Exceptions

\ArangoDBClient\Exception

Returns

boolean- always true, will throw if there is an error

Replace an existing document in a collection, identified by the document itself

replace(\ArangoDBClient\Document $document, array $options = array()) : boolean
Inherited

This will replace the document on the server

This will throw if the document 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 document is the same as the one given.

Parameters

$document

\ArangoDBClient\Document
  • document to be replaced

$options

array
  • optional, array of options

    Options are :

  • 'policy' - replace policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • 'waitForSync' - 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

Exceptions

\ArangoDBClient\Exception

Returns

boolean- always true, will throw if there is an error

Replace an existing document in a collection, identified by collection id and document id

replaceById(mixed $collection, mixed $documentId, \ArangoDBClient\Document $document, array $options = array()) : boolean
Inherited

This will update the document on the server

This will throw if the document 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 document is the same as the one given.

Parameters

$collection

mixed
  • collection id as string or number

$documentId

mixed
  • document id as string or number

$document

\ArangoDBClient\Document
  • document to be updated

$options

array
  • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • 'waitForSync' - 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

Exceptions

\ArangoDBClient\Exception

Returns

boolean- always true, will throw if there is an error

Insert a document into a collection

save($collection, $document, array $options = array()
Inherited

This is an alias for insert().

Parameters

$collection

$document

$options

save an edge to an edge-collection

saveEdge(mixed $collection, mixed $from, mixed $to, mixed $document, array $options = array()) : mixed

This will save the edge to the collection and return the edges-document's id

This will throw if the document cannot be saved

since 1.0

Parameters

$collection

mixed
  • collection id as string or number

$from

mixed
  • from vertex

$to

mixed
  • to vertex

$document

mixed
  • the edge-document to be added, can be passed as an object or an array

$options

array
  • optional, array of options.

    Options are :

  • 'createCollection' - create the collection if it does not yet exist.
  • 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk.
    If this is not specified, then the collection's default sync behavior will be applied.

Exceptions

\ArangoDBClient\Exception

Returns

mixed- id of document created

Sets the document class to use

setDocumentClass(string $class) : \ArangoDBClient\DocumentClassable
Inherited

Parameters

$class

string

Document class to use

Returns

\ArangoDBClient\DocumentClassable

Sets the edge class to use

setEdgeClass(string $class) : \ArangoDBClient\DocumentClassable
Inherited

Parameters

$class

string

Edge class to use

Returns

\ArangoDBClient\DocumentClassable

Store a document to a collection

store(\ArangoDBClient\Document $document, mixed $collection = null, array $options = array()) : mixed
Inherited

This is an alias/shortcut to save() and replace(). Instead of having to determine which of the 3 functions to use, simply pass the document to store() and it will figure out which one to call.

This will throw if the document cannot be saved or replaced.

since 1.0

Parameters

$document

\ArangoDBClient\Document
  • the document to be added, can be passed as a document or an array

$collection

mixed
  • collection id as string or number

$options

array
  • optional, array of options

    Options are :

  • 'createCollection' - create the collection if it does not yet exist.
  • 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.

Exceptions

\ArangoDBClient\Exception

Returns

mixed- id of document created

Update an existing document in a collection, identified by the including _id and optionally _rev in the patch document.

update(\ArangoDBClient\Document $document, array $options = array()) : boolean
Inherited

Attention - The behavior of this method has changed since version 1.1

This will update the document on the server

This will throw if the document cannot be updated

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 document to-be-replaced is the same as the one given.

Parameters

$document

\ArangoDBClient\Document
  • The patch document that will update the document in question

$options

array
  • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • 'keepNull' - 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)
  • 'waitForSync' - 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

Exceptions

\ArangoDBClient\Exception

Returns

boolean- always true, will throw if there is an error

Update an existing document in a collection, identified by collection id and document id Attention - The behavior of this method has changed since version 1.1

updateById(string $collection, mixed $documentId, \ArangoDBClient\Document $document, array $options = array()) : boolean
Inherited

This will update the document on the server

This will throw if the document cannot be updated

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 document to-be-updated is the same as the one given.

Parameters

$collection

string
  • collection id as string or number

$documentId

mixed
  • document id as string or number

$document

\ArangoDBClient\Document
  • patch document which contains the attributes and values to be updated

$options

array
  • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • 'keepNull' - 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)
  • 'waitForSync' - 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

Exceptions

\ArangoDBClient\Exception

Returns

boolean- always true, will throw if there is an error

Add a transaction header to the array of headers in case this is a transactional operation

addTransactionHeader(array $headers, mixed $collection) 
Inherited

Parameters

$headers

array
  • already existing headers

$collection

mixed
  • any type of collection (can be StreamingTransactionCollection or other)

Intermediate function to call the createFromArray function from the right context

createFromArrayWithContext($data, $options) : \ArangoDBClient\Document
Inherited

Parameters

$data

$options

Exceptions

\ArangoDBClient\ClientException

Returns

\ArangoDBClient\Document

Return the connection object

getConnection() : \ArangoDBClient\Connection
Inherited

Returns

\ArangoDBClient\Connection- the connection object

Return a connection option This is a convenience function that calls json_encode_wrapper on the connection

getConnectionOption($optionName) : mixed
Inherited

Parameters

$optionName

  • The option to return a value for

Exceptions

\ArangoDBClient\ClientException

Returns

mixed- the option's value

Helper function that runs through the options given and includes them into the parameters array given.

includeOptionsInBody(array $options, array $body, array $includeArray = array()) : array
Inherited

Only options that are set in $includeArray will be included. This is only for options that are to be sent to the ArangoDB server in a json body(like 'limit', 'skip', etc...) .

Parameters

$options

array
  • The options array that holds the options to include in the parameters

$body

array
  • The array into which the options will be included.

$includeArray

array
  • The array that defines which options are allowed to be included, and what their default value is. for example: 'waitForSync'=>true

Returns

array$params - array of parameters for use in a url

Return a json encoded string for the array passed.

json_encode_wrapper(array $body) : string
Inherited

This is a convenience function that calls json_encode_wrapper on the connection

Parameters

$body

array
  • The body to encode into json

Exceptions

\ArangoDBClient\ClientException

Returns

string- json string of the body that was passed

lazyCreateCollection()

lazyCreateCollection(mixed $collection, array $options) 
inherited_from \ArangoDBClient\DocumentHandler::lazyCreateCollection()

Parameters

$collection

mixed collection name or id

$options

array
  • optional, array of options

    Options are :

  • 'createCollection' - true to create the collection if it does not exist
  • 'createCollectionType' - "document" or 2 for document collection
  • "edge" or 3 for edge collection

lazyCreateCollection()

lazyCreateCollection(mixed $collection, array $options) 
Inherited

Parameters

$collection

mixed

collection name or id

$options

array
  • optional, array of options

    Options are :

  • 'createCollectionType' - "document" or 2 for document collection
  • "edge" or 3 for edge collection
  • 'waitForSync' - if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.

Turn a value into a collection name

makeCollection(mixed $value) : string
Inherited

Parameters

$value

mixed
  • document, collection or string

Exceptions

\ArangoDBClient\ClientException

Returns

string- collection name

Helper function to get a document id from a document or a document id value

getDocumentId(mixed $document) : mixed
Inherited

Parameters

$document

mixed
  • document id OR document to be updated

Exceptions

\ArangoDBClient\ClientException

Returns

mixed- document id, will throw if there is an error

Helper function to get a document id from a document or a document id value

getRevision(mixed $document) : mixed
Inherited

Parameters

$document

mixed
  • document id OR document to be updated

Exceptions

\ArangoDBClient\ClientException

Returns

mixed- document id, will throw if there is an error

 Properties

 

Document class to use

$_documentClass : string

Default

'\ArangoDBClient\Document'
 

Edge class to use

$_edgeClass : string

Default

'\ArangoDBClient\Edge'
 

Connection object

$_connection 

Default

param

 Constants

 

documents array index

ENTRY_DOCUMENTS = 'edge' 
inherited_from \ArangoDBClient\DocumentHandler::ENTRY_DOCUMENTS
 

documents array index

ENTRY_DOCUMENTS = 'documents' 
 

edges array index

ENTRY_EDGES = 'edges' 
 

collection parameter

OPTION_COLLECTION = 'collection' 
inherited_from \ArangoDBClient\DocumentHandler::OPTION_COLLECTION
 

collection parameter

OPTION_COLLECTION = 'collection' 
 

direction parameter

OPTION_DIRECTION = 'direction' 
 

example parameter

OPTION_EXAMPLE = 'example' 
inherited_from \ArangoDBClient\DocumentHandler::OPTION_EXAMPLE
 

example parameter

OPTION_EXAMPLE = 'example' 
 

example parameter

OPTION_FROM = 'from' 
 

overwrite option

OPTION_OVERWRITE = 'overwrite' 
 

option for returning the new document

OPTION_RETURN_NEW = 'returnNew' 
 

option for returning the old document

OPTION_RETURN_OLD = 'returnOld' 
 

example parameter

OPTION_TO = 'to' 
 

vertex parameter

OPTION_VERTEX = 'vertex'