Base Plugin Class
Every plugin should extend from this class or implement the interfaces and include a plugin class in its src root folder.
array<string> ['bootstrap', 'console', 'middleware', 'routes', 'services']
List of valid hooks.
boolDo bootstrapping or not
stringThe class path for this plugin.
stringThe config path for this plugin.
boolConsole middleware
boolEnable middleware
stringThe name of this plugin
stringThe path to this plugin.
boolLoad routes or not
boolRegister container services
stringThe templates path for this plugin.
Constructor
Load all the application configuration and bootstrap logic.
Check if a hook name is valid
Add console commands for the plugin.
Disables the named hook
Enables the named hook
Get the filesystem path to configuration for this plugin
Get the filesystem path to configuration for this plugin
Get the name of this plugin.
Get the filesystem path to this plugin
Get the filesystem path to templates for this plugin
Initialization hook called from constructor.
Check if the named hook is enabled
Add middleware for the plugin.
Add routes for the plugin.
Register container services for this plugin.
__construct(array<string, mixed> $options = [])
Constructor
array<string, mixed> $options optional Options
bootstrap(Cake\Core\PluginApplicationInterface $app): void
Load all the application configuration and bootstrap logic.
The default implementation of this method will include the config/bootstrap.php in the plugin if it exist. You can override this method to replace that behavior.
The host application is provided as an argument. This allows you to load additional plugin dependencies, or attach events.
Cake\Core\PluginApplicationInterface $app voidcheckHook(string $hook): void
Check if a hook name is valid
string $hook The hook name to check
voidInvalidArgumentExceptionconsole(Cake\Console\CommandCollection $commands): Cake\Console\CommandCollection
Add console commands for the plugin.
Cake\Console\CommandCollection $commands Cake\Console\CommandCollectiondisable(string $hook): $this
Disables the named hook
string $hook $thisenable(string $hook): $this
Enables the named hook
string $hook $thisgetClassPath(): string
Get the filesystem path to configuration for this plugin
stringgetConfigPath(): string
Get the filesystem path to configuration for this plugin
stringgetName(): string
Get the name of this plugin.
stringgetPath(): string
Get the filesystem path to this plugin
stringgetTemplatePath(): string
Get the filesystem path to templates for this plugin
stringinitialize(): void
Initialization hook called from constructor.
voidisEnabled(string $hook): bool
Check if the named hook is enabled
string $hook boolmiddleware(Cake\Http\MiddlewareQueue $middlewareQueue): Cake\Http\MiddlewareQueue
Add middleware for the plugin.
Cake\Http\MiddlewareQueue $middlewareQueue Cake\Http\MiddlewareQueueroutes(Cake\Routing\RouteBuilder $routes): void
Add routes for the plugin.
The default implementation of this method will include the config/routes.php in the plugin if it exists. You can override this method to replace that behavior.
Cake\Routing\RouteBuilder $routes voidservices(Cake\Core\ContainerInterface $container): void
Register container services for this plugin.
Cake\Core\ContainerInterface $container The container to add services to.
voidDo bootstrapping or not
boolThe class path for this plugin.
stringThe config path for this plugin.
stringConsole middleware
boolEnable middleware
boolThe name of this plugin
stringThe path to this plugin.
stringLoad routes or not
boolRegister container services
boolThe templates path for this plugin.
string
© 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.BasePlugin.html