Jelix 1.8.13

jEvent
in package
implements EventInterface

Class which represents an event in the event system.

Tags
subpackage

events

Interfaces, Classes and Traits

EventInterface
Interface for event classes

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>>
__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
do nothing. Use \jApp::reloadServices() instead
getName()  : string
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()  : object|jEvent
Send a notification to all modules.
getBoolResponseByKey()  : null|bool
get a response value as boolean.

Constants

RESPONSE_AND_OPERATOR

public mixed RESPONSE_AND_OPERATOR = 0
Tags

RESPONSE_OR_OPERATOR

public mixed RESPONSE_OR_OPERATOR = 1
Tags

Properties

$_name

The name of the event.

protected string $_name

name

Tags

$_params

the event parameters.

protected mixed $_params
Tags

$_responses

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

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

Tags
author

Copix Team

Return values
mixed

__get()

get a user param.

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

the parameter name

Tags
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

Tags
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

Tags
author

Copix Team

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()

do nothing. Use \jApp::reloadServices() instead

public static clearCache() : mixed
Tags
deprecated
Return values
mixed

getName()

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

public getName() : string
Tags
author

Copix Team

Return values
string

the name of the event.

getParam()

gets the given param.

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

the param name

Tags
deprecated

since Jelix 1.6

author

Copix Team

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>>
Tags
author

Copix Team

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

Tags
author

Copix Team

Return values
bool

whether or not we have founded the response value

notify()

Send a notification to all modules.

public static notify(string|jEvent $eventName[, mixed $params = array() ]) : object|jEvent

Possibility to use your own event object, derived from jEvent, and having its own methods and properties. It allows to listeners to give returned data in a better way than using the add method.

Prefer to use \jApp::services()->eventDispatcher()->dispatch($event) for event objects.

Parameters
$eventName : string|jEvent

the event name or an event object

$params : mixed = array()
Tags
Return values
object|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

Search results