Class cGenericDb.

Handles the generic execution of callbacks.

copyright four for business AG

 Methods

Registers a new callback.

register(string $event, mixed $callback, mixed $class) : void
Static

Example: cGenericDb::register(cGenericDb::CREATE_SUCCESS, 'itemCreateHandler', 'cApiArticle'); cGenericDb::register(cGenericDb::CREATE_SUCCESS, array('cCallbackHandler', 'executeCreateHandle'), 'cApiArticle');

Parameters

$event

string

Callback event, must be a valid value of a cGenericDb event constant

$callback

mixed

Callback to register

$class

mixed

Class name for registering callback (can be string of array with names of the concrete Item classes)

Exceptions

\cInvalidArgumentException if event or class are not set or the callback is not callable

Unregisters all callbacks for a specific event in a class.

unregister(string $event, mixed $class) : void
Static

Example: cGenericDb::unregister(cGenericDb::CREATE_SUCCESS, 'cApiArticle');

Parameters

$event

string

Callback event, must be a valid value of a cGenericDb event constant

$class

mixed

Class name for unregistering callback (can be string of array with names of the concrete Item classes)

Exceptions

\cInvalidArgumentException if the event or the class are not set

Executes all callbacks for a specific event in a class.

_executeCallbacks(string $event, string $class, array $arguments) : void

Parameters

$event

string

Callback event, must be a valid value of a cGenericDb event constant

$class

string

Class name for executing callback

$arguments

array

Arguments to pass to the callback function

Exceptions

\cInvalidArgumentException if the event or class is not set

 Properties

 

$_callbacks : array

 Constants

 

Callbacks are executed before a item is created.

CREATE_BEFORE 

Expected parameters for callback: none

 

Callbacks are executed if item could not be created.

CREATE_FAILURE 

Expected parameters for callback: none

 

Callbacks are executed if item could be created successfully.

CREATE_SUCCESS 

Expected parameters for callback: ID of created item

 

Callbacks are executed before deleting an item.

DELETE_BEFORE 

Expected parameters for callback: ID of them item to delete

 

Callbacks are executed if deletion of an item fails.

DELETE_FAILURE 

Expected parameters for callback: ID of them item to delete

 

Callbacks are executed if item was deleted successfully.

DELETE_SUCCESS 

Expected parameters for callback: ID of them item to delete

 

Callbacks are executed before store process is executed.

STORE_BEFORE 

Expected parameters for callback: Item instance

 

Callbacks are executed if store process failed.

STORE_FAILURE 

This is also likely to happen if query would not change anything in database! Expected parameters for callback: Item instance

 

Callbacks are executed if store process saved the values in the database.

STORE_SUCCESS 

Expected parameters for callback: Item instance