PHP Class flight\core\Dispatcher

Exibir arquivo Open project: mikecao/flight Class Usage Examples

Protected Properties

Property Type Description
$events array Mapped events.
$filters array Method filters.

Public Methods

Method Description
callFunction ( string $func, array &$params = [] ) : mixed Calls a function.
clear ( string $name = null ) Clears an event. If no name is given, all events are removed.
execute ( callback $callback, array &$params = [] ) : mixed Executes a callback function.
filter ( array $filters, array &$params, mixed &$output ) Executes a chain of method filters.
get ( string $name ) : callback Gets an assigned callback.
has ( string $name ) : boolean Checks if an event has been set.
hook ( string $name, string $type, callback $callback ) Hooks a callback to an event.
invokeMethod ( mixed $func, array &$params = [] ) : mixed Invokes a method.
reset ( ) Resets the object to the initial state.
run ( string $name, array $params = [] ) : string Dispatches an event.
set ( string $name, callback $callback ) Assigns a callback to an event.

Method Details

callFunction() public static method

Calls a function.
public static callFunction ( string $func, array &$params = [] ) : mixed
$func string Name of function to call
$params array Function parameters
return mixed Function results

clear() public method

Clears an event. If no name is given, all events are removed.
public clear ( string $name = null )
$name string Event name

execute() public static method

Executes a callback function.
public static execute ( callback $callback, array &$params = [] ) : mixed
$callback callback Callback function
$params array Function parameters
return mixed Function results

filter() public method

Executes a chain of method filters.
public filter ( array $filters, array &$params, mixed &$output )
$filters array Chain of filters
$params array Method parameters
$output mixed Method output

get() public method

Gets an assigned callback.
public get ( string $name ) : callback
$name string Event name
return callback $callback Callback function

has() public method

Checks if an event has been set.
public has ( string $name ) : boolean
$name string Event name
return boolean Event status

hook() public method

Hooks a callback to an event.
public hook ( string $name, string $type, callback $callback )
$name string Event name
$type string Filter type
$callback callback Callback function

invokeMethod() public static method

Invokes a method.
public static invokeMethod ( mixed $func, array &$params = [] ) : mixed
$func mixed Class method
$params array Class method parameters
return mixed Function results

reset() public method

Resets the object to the initial state.
public reset ( )

run() public method

Dispatches an event.
public run ( string $name, array $params = [] ) : string
$name string Event name
$params array Callback parameters
return string Output of callback

set() public method

Assigns a callback to an event.
public set ( string $name, callback $callback )
$name string Event name
$callback callback Callback function

Property Details

$events protected_oe property

Mapped events.
protected array $events
return array

$filters protected_oe property

Method filters.
protected array $filters
return array