FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Event Class Reference

Event handler component. More...

Inheritance diagram for Event:
Component Thing

Public Member Functions

 listen ($name, $callback, $prio=50)
 Start listening to an event. More...
 
 trigger ($name, $sender=null)
 Trigger an event. More...
 
 count ($name)
 Number of times an event has been triggered. More...
 
- Public Member Functions inherited from Component
 __construct ($fred, $config=null)
 
 __destruct ()
 
 clientConfig ()
 Public configuration. More...
 
 config ($key, $default=null)
 Retrieve a config value. More...
 
 ping ()
 Ping function. More...
 
 filemtime ($filename)
 Filemtime with session cache. More...
 
 component ($name)
 Get a component (local or default). More...
 
 components (... $names)
 Get multiple components in an array. More...
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Protected Attributes

 $_events = []
 
 $_counts = []
 
- Protected Attributes inherited from Component
 $_fred = null
 
 $_config = null
 
 $_name = null
 
 $_components = []
 Local components (key = component name, value = component). More...
 
 $_session = null
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 

Additional Inherited Members

- Data Fields inherited from Component
 $filemtimeTtl = 0
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 
- Protected Member Functions inherited from Component
 init ()
 
 done ()
 
 getSession ()
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 configure ($config)
 Configure the object. More...
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Detailed Description

Event handler component.

Definition at line 8 of file Event.php.

Member Function Documentation

◆ count()

count (   $name)

Number of times an event has been triggered.

Parameters
string$nameName of the event (usually with a class name prefix).
Returns
int Counter (false if event does not exist).

Definition at line 49 of file Event.php.

◆ listen()

listen (   $name,
  $callback,
  $prio = 50 
)

Start listening to an event.

Parameters
string$nameName of the event (usually with a class name prefix).
function$callbackCallback function (first parameter must be the sender; others are event specific).
int$prioCallbacks with a lower prio value are called before ones with higher values. Otherwise callbacks are called in the order in which they where added.

Definition at line 20 of file Event.php.

◆ trigger()

trigger (   $name,
  $sender = null 
)

Trigger an event.

Parameters
string$nameName of the event (usually with a class name prefix).
object$sender,...The initiator of the event, and other parameters for the callback function.
Returns
mixed Return value if one of the callbacks returned something other than null (this will also directly stop the chain). Returns null if none of the callbacks functions (if any) returned anything other than null.

Definition at line 32 of file Event.php.

Field Documentation

◆ $_counts

$_counts = []
protected

Definition at line 11 of file Event.php.

◆ $_events

$_events = []
protected

Definition at line 10 of file Event.php.


The documentation for this class was generated from the following file: