A handler that manages users

. A user-document handler that fetches vertices 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.2
inherited_from \ArangoDBClient\Handler

 Methods

Construct a new handler

__construct(\ArangoDBClient\Connection $connection) 
Inherited

Parameters

$connection

\ArangoDBClient\Connection
  • connection to be used

save a user to the user-collection

addUser(string $username, mixed $passwd = null, mixed $active = null, array $extra = null) : boolean

This will save the user to the users collection. It will additionally grant the user permissions for the current database

This will throw if the user cannot be saved

since 1.2

Parameters

$username

string
  • The name of the user as a string. This is mandatory.

$passwd

mixed
  • The user password as a string. If no password is specified, the empty string will be used.

$active

mixed
  • an optional flag that specifies whether the user is active. If not specified, this will default to true.

$extra

array
  • an optional array with arbitrary extra data about the user.

Exceptions

\ArangoDBClient\Exception

Returns

boolean- true, if user could be saved

Get a single user-document, identified by the username

get(string $username) : \ArangoDBClient\User

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

Parameters

$username

string
  • username as a string

Exceptions

\ArangoDBClient\Exception

Returns

\ArangoDBClient\User- the user-document fetched from the server

Gets the list of collections a user has access to

getCollectionPermissionLevel(string $username, string $databaseName, string $collectionName) : string

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of the database

$collectionName

string
  • name of the collection

Returns

string

Gets the list of collections a user has access to

getDatabasePermissionLevel(string $username, string $databaseName) : string

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of the database

Returns

string

Gets the list of databases a user has access to

getDatabases(string $username) : array

Parameters

$username

string
  • username as a string

Exceptions

\ArangoDBClient\Exception

Returns

arrayof database names for the databases the user has access to

Grant R/W permissions to a user, for a specific collection

grantCollectionPermissions(string $username, string $databaseName, string $collectionName, string $permissions = 'rw') : boolean

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of database as a string

$collectionName

string
  • name of collection as a string

$permissions

string
  • permissions string rw for read-write (default), ro for read-only

Returns

boolean

Grant R/W permissions to a user, for a specific database

grantDatabasePermissions(string $username, string $databaseName, string $permissions = 'rw') : boolean

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of database as a string

$permissions

string
  • permissions string rw for read-write (default), ro for read-only

Returns

boolean

Grant R/W permissions to a user, for a specific database

grantPermissions(string $username, string $databaseName) : boolean
deprecated use UserHandler::grantDatabasePermissions instead

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of database as a string

Exceptions

\ArangoDBClient\Exception

Returns

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

Remove a user, identified by the username

removeUser(string $username) : boolean

Parameters

$username

string
  • username as a string, of the user that is to be deleted

Exceptions

\ArangoDBClient\Exception

Returns

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

Replace an existing user, identified by its username

replaceUser(string $username, mixed $passwd = null, mixed $active = null, array $extra = null) : boolean

This will replace the user-document on the server

This will throw if the document cannot be replaced

Parameters

$username

string
  • The name of the user as a string, who's user-data is going to be replaced. This is mandatory.

$passwd

mixed
  • The user password as a string. If no password is specified, the empty string will be used.

$active

mixed
  • an optional flag that specifies whether the user is active. If not specified, this will default to true.

$extra

array
  • an optional array with arbitrary extra data about the user.

Exceptions

\ArangoDBClient\Exception

Returns

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

Revoke R/W permissions for a user, for a specific database

revokeCollectionPermissions(string $username, string $databaseName, string $collectionName) : boolean

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of database as a string

$collectionName

string
  • name of collection as a string

Exceptions

\ArangoDBClient\Exception

Returns

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

Revoke R/W permissions for a user, for a specific database

revokeDatabasePermissions(string $username, string $databaseName) : boolean

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of database as a string

Exceptions

\ArangoDBClient\Exception

Returns

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

Revoke R/W permissions for a user, for a specific database

revokePermissions(string $username, string $databaseName) : boolean
deprecated use UserHandler::revokeDatabasePermissions instead

Parameters

$username

string
  • username as a string

$databaseName

string
  • name of database as a string

Exceptions

\ArangoDBClient\Exception

Returns

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

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

Update an existing user, identified by the username

updateUser(string $username, mixed $passwd = null, mixed $active = null, array $extra = null) : boolean

This will update the user-document on the server

This will throw if the document cannot be updated

Parameters

$username

string
  • The name of the user as a string, who's user-data is going to be updated. This is mandatory.

$passwd

mixed
  • The user password as a string. If no password is specified, the empty string will be used.

$active

mixed
  • an optional flag that specifies whether the user is active. If not specified, this will default to true.

$extra

array
  • an optional array with arbitrary extra data about the user.

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)

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

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

 Properties

 

Document class to use

$_documentClass : string

Default

'\ArangoDBClient\Document'
 

Edge class to use

$_edgeClass : string

Default

'\ArangoDBClient\Edge'
 

Connection object

$_connection 

Default

param