Source API for the «PorteEvents» class
Static methods used the manage and call events at the global level.
Public static methods
- connect
-
Register new event called at a static level. Events can be glabal, for all records, or specific to the record type (associated with the record destination table)
The return key is structured as follow:
- ('global_type'||'records_type').'-'.table_name.'-'.event_name.'-'.method
- ('global_type'||'records_type').'-'.table_name.'-'.event_name.'-'.object_hash.'-'.$method
Registering a function listener:
PorteEvents::connect('record_create_before','beforeOnCreateListener'); PorteEvents::connect('record_type','record_create_before','beforeOnCreateListener');Registering a method listener:
PorteEvents::connect('record_create_before',array($listener,'beforeOnCreateListener')); PorteEvents::connect('record_type','record_create_before',array($listener,'beforeOnCreateListener')); -
- return
- string
- Event name
- disconnect
-
There are two ways to disconnect an event, either using the same parameters as the one used when connecting the event or using the key returned by the "connect" method.
Disconnecting a global event using the same parameters:
PorteEvents::connect('action','function'); PorteEvents::disconnect('action','function'); PorteEvents::connect('action',$object,'method'); PorteEvents::disconnect('action',$object,'method');Disconnecting a global event using the returned key:
$event = PorteEvents::connect('action','function'); PorteEvents::disconnect($event); $event = PorteEvents::connect('action',$object,'method'); PorteEvents::disconnect($event);Disconnecting a records event using the same parameters:
PorteEvents::connect('record_type','action','function'); PorteEvents::disconnect('record_type','action','function'); PorteEvents::connect('record_type','action',$object,'method'); PorteEvents::disconnect('record_type','action',$object,'method');Disconnecting a records event using the returned key:
$event = PorteEvents::connect('record_type','action','function'); PorteEvents::disconnect($event); $event = PorteEvents::connect('record_type','action',$object,'method'); PorteEvents::disconnect($event); -
- return
- boolean
- on success
- call
-
Call a static event. If calling a global event, each registered listener will be called (in their chronological registration order) until one return a value not null which is then returned by the method.
If calling a records event, we first call the global events and apply the same process to the registered records listeners.Exemple calling a static global event:
PorteEvents::call($eventName,$args)Exemple calling a static records event:
PorteEvents::call($table,$eventName,$args) -
- return
- mixed
- The value return by an event or null
- release
-
At this stage, this method is a hack to satisfy Hierarchical tests
-
- return
- null