Provides management of user-functions

AqlUserFunction object
An AqlUserFunction is an object that is used to manage AQL User Functions.
It registers, un-registers and lists user functions on the server

The object encapsulates:

  • the name of the function
  • the actual javascript function


The object requires the connection object and can be initialized with or without initial configuration.

Any configuration can be set and retrieved by the object's methods like this:

$this->setName('myFunctions:myFunction');
$this->setCode('function (){your code};');


or like this:

$this->name('myFunctions:myFunction');
$this->code('function (){your code};');
package ArangoDBClient
since 1.3

 Methods

Initialise the AqlUserFunction object

__construct(\ArangoDBClient\Connection $connection, array $attributesArray = null

The $attributesArray array can be used to specify the name and code for the user function in form of an array.

Example: array( 'name' => 'myFunctions:myFunction', 'code' => 'function (){}' )

Parameters

$connection

\ArangoDBClient\Connection
  • the connection to be used

$attributesArray

array
  • user function initialization data

Exceptions

\ArangoDBClient\ClientException

Get an attribute, magic method

__get(string $key) : mixed

This function is mapped to get() internally.

magic

Parameters

$key

string
  • name of attribute

Returns

mixed- value of attribute, NULL if attribute is not set

Is triggered by calling isset() or empty() on inaccessible properties.

__isset(string $key) : boolean

Parameters

$key

string
  • name of attribute

Returns

booleanreturns true or false (set or not set)

Set an attribute, magic method

__set(string $key, mixed $value) 

This is a magic method that allows the object to be used without declaring all attributes first.

magic

Parameters

$key

string
  • attribute name

$value

mixed
  • value for attribute

Exceptions

\ArangoDBClient\ClientException

Build the object's attributes from a given array

buildAttributesFromArray($options) 

Parameters

$options

Exceptions

\ArangoDBClient\ClientException

Get an attribute

get(string $key) : mixed

Parameters

$key

string
  • name of attribute

Returns

mixed- value of attribute, NULL if attribute is not set

Get user function code

getCode() : string

Returns

stringname

Get name value

getName() : string

Returns

stringname

Get registered user functions

getRegisteredUserFunctions(null $namespace = null) : mixed

The method can optionally be passed a $namespace parameter to narrow the results down to a specific namespace.

Parameters

$namespace

null

Exceptions

\ArangoDBClient\Exception throw exception if the request failed

Returns

mixedtrue if successful without a return value or the return value if one was set in the action

Registers the user function

register(null $name = null, null $code = null) : mixed

If no parameters ($name,$code) are passed, it will use the properties of the object.

If $name and/or $code are passed, it will override the object's properties with the passed ones

Parameters

$name

null

$code

null

Exceptions

\ArangoDBClient\Exception throws exception if registration failed

Returns

mixedtrue if registration was successful.

Set an attribute

set($key, $value) : \ArangoDBClient\AqlUserFunction
fluent This method is part of a fluent interface and will return the same instance

Parameters

$key

$value

Exceptions

\ArangoDBClient\ClientException

Returns

\ArangoDBClient\AqlUserFunction

Set user function code

setCode(string $value) 

Parameters

$value

string

Exceptions

\ArangoDBClient\ClientException

Set name of the user function. It must have at least one namespace, but also can have sub-namespaces.

setName(string $value) 

correct: 'myNamespace:myFunction' 'myRootNamespace:mySubNamespace:myFunction'

wrong: 'myFunction'

Parameters

$value

string

Exceptions

\ArangoDBClient\ClientException

Un-register the user function

unregister(string $name = null, boolean $namespace = false) : mixed

If no parameter ($name) is passed, it will use the property of the object.

If $name is passed, it will override the object's property with the passed one

Parameters

$name

string

$namespace

boolean

Exceptions

\ArangoDBClient\Exception throw exception if the request fails

Returns

mixedtrue if successful without a return value or the return value if one was set in the action

Return the connection object

getConnection() : \ArangoDBClient\Connection

Returns

\ArangoDBClient\Connection- the connection object

 Properties

 

- The code of the user function

$code : string

Default

magic
property - The code of the user function
 

- The name of the user function

$name : string

Default

magic
property - The name of the user function
 

The function's attributes.

$attributes : array

Default

array()
 

The connection object

$_connection : \ArangoDBClient\Connection

Default

 Constants

 

Action index

ENTRY_CODE = 'code' 
 

Collections index

ENTRY_NAME = 'name'