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.
bool
Do bootstrapping or not
string
The class path for this plugin.
string
The config path for this plugin.
bool
Console middleware
bool
Enable middleware
string
The name of this plugin
string
The path to this plugin.
bool
Load routes or not
bool
Register container services
string
The 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 void
checkHook(string $hook): void
Check if a hook name is valid
string
$hook The hook name to check
void
InvalidArgumentException
console(Cake\Console\CommandCollection $commands): Cake\Console\CommandCollection
Add console commands for the plugin.
Cake\Console\CommandCollection
$commands Cake\Console\CommandCollection
disable(string $hook): $this
Disables the named hook
string
$hook $this
enable(string $hook): $this
Enables the named hook
string
$hook $this
getClassPath(): string
Get the filesystem path to configuration for this plugin
string
getConfigPath(): string
Get the filesystem path to configuration for this plugin
string
getName(): string
Get the name of this plugin.
string
getPath(): string
Get the filesystem path to this plugin
string
getTemplatePath(): string
Get the filesystem path to templates for this plugin
string
initialize(): void
Initialization hook called from constructor.
void
isEnabled(string $hook): bool
Check if the named hook is enabled
string
$hook bool
middleware(Cake\Http\MiddlewareQueue $middlewareQueue): Cake\Http\MiddlewareQueue
Add middleware for the plugin.
Cake\Http\MiddlewareQueue
$middlewareQueue Cake\Http\MiddlewareQueue
routes(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 void
services(Cake\Core\ContainerInterface $container): void
Register container services for this plugin.
Cake\Core\ContainerInterface
$container The container to add services to.
void
Do bootstrapping or not
bool
The class path for this plugin.
string
The config path for this plugin.
string
Console middleware
bool
Enable middleware
bool
The name of this plugin
string
The path to this plugin.
string
Load routes or not
bool
Register container services
bool
The 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