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.
intLoop 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.
$thisclear(): $this
Remove all plugins from the collection
$thiscount(): int
Implementation of Countable.
Get the number of plugins in the collection.
intcreate(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\PluginInterfaceCake\Core\Exception\MissingPluginExceptioncurrent(): Cake\Core\PluginInterface
Part of Iterator Interface
Cake\Core\PluginInterfacefindPath(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.
stringCake\Core\Exception\MissingPluginExceptionget(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\PluginInterfaceCake\Core\Exception\MissingPluginExceptionhas(string $name): bool
Check whether the named plugin exists in the collection.
string $name The named plugin.
boolkey(): string
Part of Iterator Interface
stringloadConfig(): 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/
voidnext(): void
Part of Iterator Interface
voidremove(string $name): $this
Remove a plugin from the collection if it exists.
string $name The named plugin.
$thisrewind(): void
Part of Iterator Interface
voidvalid(): bool
Part of Iterator Interface
boolwith(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>InvalidArgumentExceptionLoop depth
intNames 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