Class PluginCollection
Plugin Collection
Holds onto plugin objects loaded into an application, and provides methods for iterating, and finding plugins based on criteria.
This class implements the Iterator interface to allow plugins to be iterated, handling the situation where a plugin's hook method (usually bootstrap) loads another plugin during iteration.
- Cake\Core\PluginCollection implements Iterator, Countable
Properties summary
Method Summary
-
__construct() public
Constructor -
add() public
Add a plugin to the collection -
clear() public
Remove all plugins from the collection -
count() public
Implementation of Countable. -
current() public
Part of Iterator Interface -
get() public
Get the a plugin by name -
has() public
Check whether the named plugin exists in the collection. -
key() public
Part of Iterator Interface -
next() public
Part of Iterator Interface -
remove() public
Remove a plugin from the collection if it exists. -
rewind() public
Part of Iterator Interface -
valid() public
Part of Iterator Interface -
with() public
Filter the plugins to those with the named hook enabled.
Method Detail
__construct() public ¶
__construct( array $plugins [] )
Constructor
Parameters
- array $plugins optional []
- The map of plugins to add to the collection.
add() public ¶
add( Cake\Core\PluginInterface
$plugin )
Add a plugin to the collection
Plugins will be keyed by their names.
Parameters
-
Cake\Core\PluginInterface
$plugin - The plugin to load.
Returns
$this
count() public ¶
count( )
Implementation of Countable.
Get the number of plugins in the collection.
Returns
Implementation of
Countable::count()
get() public ¶
get( string $name )
Get the a plugin by name
Parameters
- string $name
- The plugin to get.
Returns
Throws
has() public ¶
has( string $name )
Check whether the named plugin exists in the collection.
Parameters
- string $name
- The named plugin.
Returns
remove() public ¶
remove( string $name )
Remove a plugin from the collection if it exists.
Parameters
- string $name
- The named plugin.
Returns
$this