Contentserv PHP API

CSEvent
in package

This class is the API to handle CONTENTSERV Events.

An Event is called on one Record type, but may contain one or more Record IDs for this type. This offers the possibility to execute more performant operations for mass checks or mass operations The main methods are getRecordIDs to receive all IDs of the event and getRecords to receive all Records

The "may" - events are cancelable. You can cancel the event for one, multiple or all IDs by calling the cancel method. If it is canceled for all IDs, it is completly stopped.

Tags
access

public

since
5.1.2

Table of Contents

__toString()  : string
Returns the string representation of this event
addEventListener()  : mixed
Adds an event listener for one specific record
cancel()  : bool
Cancels the event for all or some IDs, if it is cancelable.
dispatchEvent()  : array<string|int, mixed>
Notifies the state just after the event has been executed
dispatchMayEvent()  : array<string|int, mixed>
Asks whether an event may be executed and returns the IDs of all allowed Records
dispatchOnBeforeEvent()  : array<string|int, mixed>
Notifies the state just before the event is executed
getID()  : string
Returns the unique ID of this event
getModuleName()  : string
Returns the name of the module of the Record on which the event occured
getRecord()  : Record
Returns the Record object for a given ID. If a Record had already been preloaded, it is returned.
getRecordIDs()  : array<string|int, mixed>
Returns an array containing all IDs which are accessed by this event
getRecords()  : array<string|int, mixed>
Returns all Records which are accessed by this event.
getTimestamp()  : int
Returns the timestamp when this event has been triggered
getType()  : string
Returns the type of the event
getValue()  : string
This method is optimized to load a value of a given record as fast as possible by searching the value in CONTENTSERV caches or using fastest possible methods to load.
getValues()  : array<string|int, mixed>
This method is optimized to load multiple values of given records as fast as possible by searching the value in CONTENTSERV caches or using fastest possible methods to load.
isCancelable()  : bool
Returns whether the event can be canceled for some or all IDs
isPreloaded()  : bool
Checks whether a Record has already been preloaded for a given ID.
preloadRecords()  : void
This can be used by experienced users to preload multiple missing Records at once as this is faster than loading them step by step.
stopPropagation()  : void
Stops the propagation of events further along in the remaining plugins.

Methods

__toString()

Returns the string representation of this event

public __toString() : string
Tags
access

public

Return values
string

representation

addEventListener()

Adds an event listener for one specific record

public static addEventListener(Record $record, string $type, mixed $callback[, array<string|int, mixed> $arguments = array() ][, array<string|int, mixed> $ids = null ]) : mixed
Parameters
$record : Record

the Record on which the event occurs

$type : string

the event type

$callback : mixed

the callback which is called - eigther a phpcode as string or an array([OBJECT], [METHOD])

$arguments : array<string|int, mixed> = array()

additional arguments which should be passed to the listener

$ids : array<string|int, mixed> = null

the IDs for which the event occurs or null for the current record

Tags
access

public

Return values
mixed

cancel()

Cancels the event for all or some IDs, if it is cancelable.

public cancel([mixed $ids = null ]) : bool
Parameters
$ids : mixed = null

either an ID or an array of IDs which should be canceled or NULL to cancel the event for all IDs.

Tags
access

public

Return values
bool

whether there are still IDs which are not canceled.

dispatchEvent()

Notifies the state just after the event has been executed

public static dispatchEvent(Record $record, string $type, array<string|int, mixed> $ids[, array<string|int, mixed> &$preloadedRecords = array() ][, array<string|int, mixed> $arguments = array() ]) : array<string|int, mixed>
Parameters
$record : Record

the Record on which the event occurs

$type : string

the event type

$ids : array<string|int, mixed>

the IDs for which the event occurs

$preloadedRecords : array<string|int, mixed> = array()

an array containing all preloadedRecords in the form ID => Record

$arguments : array<string|int, mixed> = array()

additional arguments

Tags
access

public

Return values
array<string|int, mixed>

IDs for which the event has been executed

dispatchMayEvent()

Asks whether an event may be executed and returns the IDs of all allowed Records

public static dispatchMayEvent(Record $record, string $type, array<string|int, mixed> $ids[, array<string|int, mixed> &$preloadedRecords = array() ][, array<string|int, mixed> $arguments = array() ]) : array<string|int, mixed>
Parameters
$record : Record

the Record on which the event occurs

$type : string

the event type

$ids : array<string|int, mixed>

the IDs for which the event occurs

$preloadedRecords : array<string|int, mixed> = array()

an array containing all preloadedRecords in the form ID => Record

$arguments : array<string|int, mixed> = array()

additional arguments

Tags
access

public

Return values
array<string|int, mixed>

IDs for which the event is allowed

dispatchOnBeforeEvent()

Notifies the state just before the event is executed

public static dispatchOnBeforeEvent(Record $record, string $type, array<string|int, mixed> $ids[, array<string|int, mixed> &$preloadedRecords = array() ][, array<string|int, mixed> $arguments = array() ]) : array<string|int, mixed>
Parameters
$record : Record

the Record on which the event occurs

$type : string

the event type

$ids : array<string|int, mixed>

the IDs for which the event occurs

$preloadedRecords : array<string|int, mixed> = array()

an array containing all preloadedRecords in the form ID => Record

$arguments : array<string|int, mixed> = array()

additional arguments

Tags
access

public

Return values
array<string|int, mixed>

IDs for which the event is executed

getID()

Returns the unique ID of this event

public getID() : string
Tags
access

public

Return values
string

ID of the event

getModuleName()

Returns the name of the module of the Record on which the event occured

public getModuleName() : string
Tags
access

public

Return values
string

the module name of the Records

getRecord()

Returns the Record object for a given ID. If a Record had already been preloaded, it is returned.

public getRecord([string $id = null ]) : Record

Otherwise the Record is loaded and returned

Parameters
$id : string = null

the ID of the Record which is requested or NULL to get any prototype Record

Tags
access

public

Return values
Record

the Record with the given ID or false if no Record exists with the given ID.

getRecordIDs()

Returns an array containing all IDs which are accessed by this event

public getRecordIDs() : array<string|int, mixed>
Tags
access

public

Return values
array<string|int, mixed>

of all accessed IDs

getRecords()

Returns all Records which are accessed by this event.

public getRecords() : array<string|int, mixed>

For faster event propagations you should check whether you required the complete Record and otherwise use the faster getRecordIDs method.

Tags
access

public

Return values
array<string|int, mixed>

of all accessed Records

getTimestamp()

Returns the timestamp when this event has been triggered

public getTimestamp() : int
Tags
access

public

Return values
int

timestamp of event initialization

getType()

Returns the type of the event

public getType() : string
Tags
access

public

Return values
string

the type of the event

getValue()

This method is optimized to load a value of a given record as fast as possible by searching the value in CONTENTSERV caches or using fastest possible methods to load.

public getValue(string $key[, string $id = null ]) : string

Whenever possible you should the getValue or getValues methods for fast performance.

Parameters
$key : string

the key of the field which is requested

$id : string = null

the ID of the Record which is requested

Tags
access

public

Return values
string

the value of the field with the given key for the requested record.

getValues()

This method is optimized to load multiple values of given records as fast as possible by searching the value in CONTENTSERV caches or using fastest possible methods to load.

public getValues(array<string|int, mixed> $keys[, array<string|int, mixed> $ids = null ]) : array<string|int, mixed>

Whenever possible you should the getValue or getValues methods for fast performance.

Parameters
$keys : array<string|int, mixed>

the key of the fields which are requested

$ids : array<string|int, mixed> = null

the IDs of the Record which are requested or NULL if all from the event

Tags
access

public

Return values
array<string|int, mixed>

an array containing all available values with the given keys for the requested records. The array has the form {[ID1] : {[KEY1]:[VALUE1], [KEY2]:[VALUE2], ...}, [ID2] : ...}

isCancelable()

Returns whether the event can be canceled for some or all IDs

public isCancelable() : bool
Tags
access

public

Return values
bool

whether the event can be canceled

isPreloaded()

Checks whether a Record has already been preloaded for a given ID.

public isPreloaded(string $id) : bool

This can be used by experienced users to use quicker queries, if Records are not already loaded.

Parameters
$id : string

the ID which should be checked

Tags
access

public

Return values
bool

whether the given ID is preloaded.

preloadRecords()

This can be used by experienced users to preload multiple missing Records at once as this is faster than loading them step by step.

public preloadRecords([mixed $ids = null ]) : void
Parameters
$ids : mixed = null

either an ID or an array of IDs which should be preload or NULL to preload all IDs of the event.

Tags
access

public

Return values
void

stopPropagation()

Stops the propagation of events further along in the remaining plugins.

public stopPropagation() : void

If called no further plugin should recieve the event. Note: The main actions are not canceled by this event

Tags
access

public

Return values
void

        

Search results