\triagens\ArangoDbAqlUserFunction

Provides management of user-functions

AqlUserFunction object
An AqlUserFunction is an object that is used to manage AQL User Functions.
It registers, unregisters 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};');

Summary

Methods
Properties
Constants
__construct()
register()
unregister()
getRegisteredUserFunctions()
setName()
getName()
setCode()
getCode()
set()
__set()
get()
__get()
__toString()
buildAttributesFromArray()
$name
$code
$
ENTRY_NAME
ENTRY_CODE
getConnection()
$attributes
$_action
N/A
No private methods found
$_connection
N/A

Constants

ENTRY_NAME

ENTRY_NAME

Collections index

ENTRY_CODE

ENTRY_CODE

Action index

Properties

$name

$name : string

  • The name of the user function

Type

string

$code

$code : string

  • The code of the user function

Type

string

$

$ : mixed

_action

Type

mixed

$attributes

$attributes : array

The transaction's attributes.

Type

array

$_action

$_action : string

The transaction's action.

Type

string

Methods

__construct()

__construct(\triagens\ArangoDb\Connection $connection, array $attributesArray) : \triagens\ArangoDb\AqlUserFunction

Initialise the AqlUserFunction object

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

\triagens\ArangoDb\Connection $connection
  • the connection to be used
array $attributesArray
  • user function initialization data

Returns

\triagens\ArangoDb\AqlUserFunction

register()

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

Registers the user function

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

null $name
null $code

Throws

\triagens\ArangoDb\Exception

throws exception if registration failed

Returns

mixed —

true if registration was successful.

unregister()

unregister(string $name, boolean $namespace) : mixed

Unregister the user function

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

string $name
boolean $namespace

Throws

\triagens\ArangoDb\Exception

throw exception if the request fails

Returns

mixed —

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

getRegisteredUserFunctions()

getRegisteredUserFunctions(null $namespace) : mixed

Get registered user functions

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

Parameters

null $namespace

Throws

\triagens\ArangoDb\Exception

throw exception if the request failed

Returns

mixed —

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

setName()

setName(string $value)

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

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

wrong: 'myFunction'

Parameters

string $value

getName()

getName() : string

Get name value

Returns

string —

name

setCode()

setCode(string $value)

Set user function code

Parameters

string $value

getCode()

getCode() : string

Get user function code

Returns

string —

name

set()

set( $key,  $value)

Set an attribute

Parameters

$key
$value

Throws

\triagens\ArangoDb\ClientException

__set()

__set(string $key, mixed $value) : void

Set an attribute, magic method

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

Parameters

string $key
  • attribute name
mixed $value
  • value for attribute

Throws

\triagens\ArangoDb\ClientException

get()

get(string $key) : mixed

Get an attribute

Parameters

string $key
  • name of attribute

Returns

mixed —
  • value of attribute, NULL if attribute is not set

__get()

__get(string $key) : mixed

Get an attribute, magic method

This function is mapped to get() internally.

Parameters

string $key
  • name of attribute

Returns

mixed —
  • value of attribute, NULL if attribute is not set

__toString()

__toString() : string

Returns the action string

Returns

string —
  • the current action string

buildAttributesFromArray()

buildAttributesFromArray( $options)

Build the object's attributes from a given array

Parameters

$options

getConnection()

getConnection() : \triagens\ArangoDb\Connection

Return the connection object

Returns

\triagens\ArangoDb\Connection
  • the connection object