Jelix 1.7.18

jEvent
in package

Class which represents an event in the event system.

Tags
subpackage

events

Table of Contents

RESPONSE_AND_OPERATOR  = 0
RESPONSE_OR_OPERATOR  = 1
$_name  : string
The name of the event.
$_params  : mixed
the event parameters.
$_responses  : array<string|int, array<string|int, mixed>>
$compilerData  : mixed
$hashListened  : array<string|int, array<string|int, jEventListener>>
hash table for event listened.
$listenersSingleton  : array<string|int, array<string|int, jEventListener>>
because a listener can listen several events, we should create only one instancy of a listener for performance, and $hashListened will contains only reference to this listener.
__construct()  : mixed
New event.
__get()  : mixed
get a user param.
__set()  : mixed
set a user param.
add()  : mixed
Adds data in the responses list.
allResponsesByKeyAreFalse()  : null|bool
says if all responses items for the given key, are equals to false.
allResponsesByKeyAreTrue()  : null|bool
says if all responses items for the given key, are equals to true.
clearCache()  : mixed
for tests.
getName()  : mixed
gets the name of the event will be used internally for optimisations.
getParam()  : null|string
gets the given param.
getParameters()  : array<string|int, mixed>
return all parameters.
getResponse()  : array<string|int, array<string|int, mixed>>
gets all the responses.
getResponseByKey()  : null|array<string|int, mixed>
get all responses value for the given key.
inResponse()  : bool
look in all the responses if we have a parameter having value as its answer.
notify()  : jEvent
send a notification to all modules.
getBoolResponseByKey()  : null|bool
get a response value as boolean.
loadListenersFor()  : mixed
construct the list of all listeners corresponding to an event.

Constants

RESPONSE_AND_OPERATOR

public mixed RESPONSE_AND_OPERATOR = 0

RESPONSE_OR_OPERATOR

public mixed RESPONSE_OR_OPERATOR = 1

Properties

$_name

The name of the event.

protected string $_name

name

$_responses

protected array<string|int, array<string|int, mixed>> $_responses = array()

$compilerData

protected static mixed $compilerData = array('jEventCompiler', 'events/jEventCompiler.class.php', 'events.xml', 'events.php')

$hashListened

hash table for event listened.

protected static array<string|int, array<string|int, jEventListener>> $hashListened = array()

$hashListened['eventName'] = array of events (by reference).

$listenersSingleton

because a listener can listen several events, we should create only one instancy of a listener for performance, and $hashListened will contains only reference to this listener.

protected static array<string|int, array<string|int, jEventListener>> $listenersSingleton = array()

Methods

__construct()

New event.

public __construct(string $name[, array<string|int, mixed> $params = array() ]) : mixed
Parameters
$name : string

the event name

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

an associative array which contains parameters for the listeners

Return values
mixed

__get()

get a user param.

public __get(string $name) : mixed
Parameters
$name : string

the parameter name

Return values
mixed

__set()

set a user param.

public __set(string $name, mixed $value) : mixed
Parameters
$name : string

the parameter name

$value : mixed

the value

Return values
mixed

add()

Adds data in the responses list.

public add(mixed $response) : mixed

if it is an array, specific items can be retrieved with getResponseByKey() getBoolResponseByKey(), or inResponse()

Parameters
$response : mixed

a single response

Return values
mixed

allResponsesByKeyAreFalse()

says if all responses items for the given key, are equals to false.

public allResponsesByKeyAreFalse(string $responseKey) : null|bool
Parameters
$responseKey : string
Tags
since
1.6.22
Return values
null|bool

null if there are no responses

allResponsesByKeyAreTrue()

says if all responses items for the given key, are equals to true.

public allResponsesByKeyAreTrue(string $responseKey) : null|bool
Parameters
$responseKey : string
Tags
since
1.6.22
Return values
null|bool

null if there are no responses

clearCache()

for tests.

public static clearCache() : mixed
Tags
since
1.5
Return values
mixed

getName()

gets the name of the event will be used internally for optimisations.

public getName() : mixed
Return values
mixed

getParam()

gets the given param.

public getParam(string $name) : null|string
Parameters
$name : string

the param name

Tags
deprecated

since Jelix 1.6

Return values
null|string

the value or null if the parameter does not exist

getParameters()

return all parameters.

public getParameters() : array<string|int, mixed>
Tags
since
1.6.30
Return values
array<string|int, mixed>

parameters

getResponse()

gets all the responses.

public getResponse() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>

associative array

getResponseByKey()

get all responses value for the given key.

public getResponseByKey(string $responseKey) : null|array<string|int, mixed>
Parameters
$responseKey : string
Tags
since
1.6.22
Return values
null|array<string|int, mixed>

list of values or null if no responses for the given item

inResponse()

look in all the responses if we have a parameter having value as its answer.

public inResponse(string $responseKey, mixed $value, array<string|int, mixed> &$response) : bool

eg, we want to know if we have failed = true in some responses, we call inResponse('failed', true, $results), and we have into $results all responses that have an item 'failed' equals to true.

Parameters
$responseKey : string

the response item we're looking for

$value : mixed

the value we're looking for

$response : array<string|int, mixed>

returned array : all full responses arrays that have the given value

Return values
bool

whether or not we have founded the response value

notify()

send a notification to all modules.

public static notify(mixed $eventname[, mixed $params = array() ]) : jEvent
Parameters
$eventname : mixed
$params : mixed = array()
Return values
jEvent

getBoolResponseByKey()

get a response value as boolean.

protected getBoolResponseByKey(string $responseKey, int $operator) : null|bool

if there are multiple response for the same key, a OR or a AND operation is made between all of response values.

Parameters
$responseKey : string
$operator : int

const RESPONSE_AND_OPERATOR or RESPONSE_OR_OPERATOR

Tags
since
1.6.22
Return values
null|bool

loadListenersFor()

construct the list of all listeners corresponding to an event.

protected static loadListenersFor(string $eventName) : mixed
Parameters
$eventName : string

the event name we wants the listeners for

Return values
mixed

Search results