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.
While its implementation supported nested iteration it does not support using continue
or break
inside loops.
int
Loop depth
array<string>
Names of plugins
arrayCake\Core\PluginInterface>
Plugin list
array<int>
Iterator position stack.
Constructor
Add a plugin to the collection
Remove all plugins from the collection
Implementation of Countable.
Create a plugin instance from a name/classname and configuration.
Part of Iterator Interface
Locate a plugin path by looking at configuration data.
Get the a plugin by name.
Check whether the named plugin exists in the collection.
Part of Iterator Interface
Load the path information stored in vendor/cakephp-plugins.php
Part of Iterator Interface
Remove a plugin from the collection if it exists.
Part of Iterator Interface
Part of Iterator Interface
Filter the plugins to those with the named hook enabled.
__construct(arrayCake\Core\PluginInterface> $plugins = [])
Constructor
arrayCake\Core\PluginInterface>
$plugins optional The map of plugins to add to the collection.
add(Cake\Core\PluginInterface $plugin): $this
Add a plugin to the collection
Plugins will be keyed by their names.
Cake\Core\PluginInterface
$plugin The plugin to load.
$this
clear(): $this
Remove all plugins from the collection
$this
count(): int
Implementation of Countable.
Get the number of plugins in the collection.
int
create(string $name, array<string, mixed> $config = []): Cake\Core\PluginInterface
Create a plugin instance from a name/classname and configuration.
string
$name The plugin name or classname
array<string, mixed>
$config optional Configuration options for the plugin.
Cake\Core\PluginInterface
Cake\Core\Exception\MissingPluginException
current(): Cake\Core\PluginInterface
Part of Iterator Interface
Cake\Core\PluginInterface
findPath(string $name): string
Locate a plugin path by looking at configuration data.
This will use the plugins
Configure key, and fallback to enumerating App::path('plugins')
This method is not part of the official public API as plugins with no plugin class are being phased out.
string
$name The plugin name to locate a path for.
string
Cake\Core\Exception\MissingPluginException
get(string $name): Cake\Core\PluginInterface
Get the a plugin by name.
If a plugin isn't already loaded it will be autoloaded on first access and that plugins loaded this way may miss some hook methods.
string
$name The plugin to get.
Cake\Core\PluginInterface
Cake\Core\Exception\MissingPluginException
has(string $name): bool
Check whether the named plugin exists in the collection.
string
$name The named plugin.
bool
key(): string
Part of Iterator Interface
string
loadConfig(): void
Load the path information stored in vendor/cakephp-plugins.php
This file is generated by the cakephp/plugin-installer package and used to locate plugins on the filesystem as applications can use extra.plugin-paths
in their composer.json file to move plugin outside of vendor/
void
next(): void
Part of Iterator Interface
void
remove(string $name): $this
Remove a plugin from the collection if it exists.
string
$name The named plugin.
$this
rewind(): void
Part of Iterator Interface
void
valid(): bool
Part of Iterator Interface
bool
with(string $hook): GeneratorCake\Core\PluginInterface>
Filter the plugins to those with the named hook enabled.
string
$hook The hook to filter plugins by
GeneratorCake\Core\PluginInterface>
InvalidArgumentException
Loop depth
int
Names of plugins
array<string>
Plugin list
arrayCake\Core\PluginInterface>
Iterator position stack.
array<int>
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Core.PluginCollection.html