Filters are provided by Amfphp to allow your contexts to 'filter into' the rest of Amfphp, i.e.
to call functions in your context at specific times
Call addFilter to register a filter, with a default priority of 10, and call callFilter to actually execute the filter
The data structure is as follows: all registered filters : associative array ( filter name => name filters) name filters : associative array containing filters for one filter name (priority => priority filters) priority filters: numbered array containing filters for one filter name and one priority [callback1, callback2, etc.]
So for example if you were to call: addFilter("FILTER_1", $obj, "method1"); addFilter("FILTER_1", $obj, "method2"); addFilter("FILTER_1", $obj, "method3", 15); addFilter("FILTER_2", $obj, "method4");
the structure would be "FILTER_1" => array( 10 => [callback for method1, callback for method2] 15 => [callback for method3] "FILTER_2" => array( 10 => [callback for method4]
This is a singleton, so use getInstance
package | Amfphp_Core |
---|---|
author | Ariel Sommeria-klein |
addFilter(String $filterName, Object $object, String $methodName, int $priority)
see | \http://php.net/manual/en/function.call-user-func.php |
---|---|
see | \http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback |
String
the name of the filter
Object
the object on which to call the method
String
the name of the method to call on the object
int
callFilters() : mixed
There can be as many parameters as necessary, but only the first one can be changed and and returned by the callees. The other parameters must be considered as context, and should not be modified by the callees, and will not be returned to the caller.
param 1: String $filterName the name of the filter which was used in addFilter( a string) following params: parameters for the function call. As many as necessary can be passed, but only the first will be filtered
mixed
the first call parameter, as filtered by the callees.__construct()
$allFilters
$instance