Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
FilterChain Class Reference

Public Member Functions

 __construct ($options=null)
 Initialize filter chain.
 
 setOptions ($options)
 
 count ()
 Return the count of attached filters.
 
 getPluginManager ()
 Get plugin manager instance.
 
 setPluginManager (FilterPluginManager $plugins)
 Set plugin manager instance.
 
 plugin ($name, array $options=[])
 Retrieve a filter plugin by name.
 
 attach ($callback, $priority=self::DEFAULT_PRIORITY)
 Attach a filter to the chain.
 
 attachByName ($name, $options=[], $priority=self::DEFAULT_PRIORITY)
 Attach a filter to the chain using a short name.
 
 merge (FilterChain $filterChain)
 Merge the filter chain with the one given in parameter.
 
 getFilters ()
 Get all the filters.
 
 filter ($value)
 Returns $value filtered through each filter in the chain.
 
 __clone ()
 Clone filters.
 
 __sleep ()
 Prepare filter chain for serialization.
 
- Public Member Functions inherited from AbstractFilter
 setOptions ($options)
 
 getOptions ()
 Retrieve options representing object state.
 
 __invoke ($value)
 Invoke filter as a command.
 

Public Attributes

const DEFAULT_PRIORITY = 1000
 Default priority at which filters are added.
 

Protected Attributes

 $plugins
 
 $filters
 
- Protected Attributes inherited from AbstractFilter
 $options = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractFilter
static hasPcreUnicodeSupport ()
 
- Static Protected Member Functions inherited from AbstractFilter
static isOptions ($options)
 

Constructor & Destructor Documentation

__construct (   $options = null)

Initialize filter chain.

Parameters
null | array | Traversable$options

Member Function Documentation

__clone ( )

Clone filters.

__sleep ( )

Prepare filter chain for serialization.

Plugin manager (property 'plugins') cannot be serialized. On wakeup the property remains unset and next invocation to getPluginManager() sets the default plugin manager instance (FilterPluginManager).

attach (   $callback,
  $priority = self::DEFAULT_PRIORITY 
)

Attach a filter to the chain.

Parameters
callable | FilterInterface$callbackA Filter implementation or valid PHP callback
int$priorityPriority at which to enqueue filter; defaults to 1000 (higher executes earlier)
Exceptions
Exception\InvalidArgumentException
Returns
self
attachByName (   $name,
  $options = [],
  $priority = self::DEFAULT_PRIORITY 
)

Attach a filter to the chain using a short name.

Retrieves the filter from the attached plugin manager, and then calls attach() with the retrieved instance.

Parameters
string$name
mixed$options
int$priorityPriority at which to enqueue filter; defaults to 1000 (higher executes earlier)
Returns
self
count ( )

Return the count of attached filters.

Returns
int
filter (   $value)

Returns $value filtered through each filter in the chain.

Filters are run in the order in which they were added to the chain (FIFO)

Parameters
mixed$value
Returns
mixed

Implements FilterInterface.

getFilters ( )

Get all the filters.

Returns
PriorityQueue
getPluginManager ( )

Get plugin manager instance.

Returns
FilterPluginManager
merge ( FilterChain  $filterChain)

Merge the filter chain with the one given in parameter.

Parameters
FilterChain$filterChain
Returns
self
plugin (   $name,
array  $options = [] 
)

Retrieve a filter plugin by name.

Parameters
mixed$name
array$options
Returns
FilterInterface
setOptions (   $options)
Parameters
array | Traversable$options
Returns
self
Exceptions
Exception\InvalidArgumentException
setPluginManager ( FilterPluginManager  $plugins)

Set plugin manager instance.

Parameters
FilterPluginManager$plugins
Returns
self

Member Data Documentation

$filters
protected
$plugins
protected
const DEFAULT_PRIORITY = 1000

Default priority at which filters are added.