Class Amfphp_Core_FilterManager

Description

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

  • author: Ariel Sommeria-klein

Located in /Amfphp/Core/FilterManager.php (line 38)


	
			
Variable Summary
static mixed $instance
mixed $allFilters
Method Summary
Amfphp_Core_FilterManager __construct ()
void addFilter (String $filterName, Object $object, String $methodName, [ $priority = 10])
mixed callFilters (String $filterName, parameters 1)
Variables
static mixed $instance = NULL (line 47)

protected instance of singleton

  • access: protected
mixed $allFilters = NULL (line 42)

all registered filters

  • access: protected
Methods
static method getInstance (line 59)
  • access: public
static Amfphp_Core_FilterManager getInstance ()
Constructor __construct (line 51)

constructor

  • access: protected
Amfphp_Core_FilterManager __construct ()
addFilter (line 115)

register an object method for the given filter

call this method in your contexts to be notified when the filter occures

void addFilter (String $filterName, Object $object, String $methodName, [ $priority = 10])
  • String $filterName: the name of the filter
  • Object $object: the object on which to call the method
  • String $methodName: the name of the method to call on the object
  • $priority
callFilters (line 75)

call the functions registered for the given filter. 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.

  • return: the first call parameter, as filtered by the callees.
  • access: public
mixed callFilters (String $filterName, parameters 1)
  • String $filterName: the name of the filter which was used in addFilter( a string)
  • parameters 1: for the function call. As many as necessary can be passed, but only the first will be filtered

Documentation generated on Tue, 29 May 2012 23:42:03 +0200 by phpDocumentor 1.4.3