Class BasePlugin
Base Plugin Class
Every plugin should extends from this class or implement the interfaces and include a plugin class in it's src root folder.
Constants summary
-
string[]VALID_HOOKS['routes', 'bootstrap', 'console', 'middleware']
Properties summary
- $bootstrapEnabled protected
boolDo bootstrapping or not
- $classPath protected
stringThe class path for this plugin.
- $configPath protected
stringThe config path for this plugin.
- $consoleEnabled protected
boolConsole middleware
- $middlewareEnabled protected
boolEnable middleware
- $name protected
stringThe name of this plugin
- $path protected
stringThe path to this plugin.
- $routesEnabled protected
boolLoad routes or not
Method Summary
Method Detail
__construct() public
__construct(array $options)
Constructor
Parameters
-
array$options optional Options
bootstrap() public
bootstrap(\Cake\Core\PluginApplicationInterface $app)
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.
Parameters
-
\Cake\Core\PluginApplicationInterface$app The host application
checkHook() protected
checkHook(mixed $hook)
Check if a hook name is valid
Parameters
-
string$hook The hook name to check
Throws
InvalidArgumentExceptionon invalid hooks
console() public
console(mixed $commands)
Add console commands for the plugin.
Parameters
-
\Cake\Console\CommandCollection$commands The command collection to update
Returns
\Cake\Console\CommandCollectiondisable() public
disable(mixed $hook)
Disables the named hook
Parameters
-
string$hook The hook to disable
Returns
$thisenable() public
enable(mixed $hook)
Enables the named hook
Parameters
-
string$hook The hook to disable
Returns
$thisgetClassPath() public
getClassPath()
Get the filesystem path to configuration for this plugin
Returns
stringgetConfigPath() public
getConfigPath()
Get the filesystem path to configuration for this plugin
Returns
stringgetName() public
getName()
Get the name of this plugin.
Returns
stringgetPath() public
getPath()
Get the filesystem path to this plugin
Returns
stringinitialize() public
initialize()
{@inheritdoc}
isEnabled() public
isEnabled(mixed $hook)
Check if the named hook is enabled
Parameters
-
string$hook The hook to check
Returns
boolmiddleware() public
middleware(mixed $middleware)
Add middleware for the plugin.
Parameters
-
\Cake\Http\MiddlewareQueue$middleware The middleware queue to update.
Returns
\Cake\Http\MiddlewareQueueroutes() public
routes(mixed $routes)
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.
Parameters
-
\Cake\Routing\RouteBuilder$routes The route builder to update.
Property Detail
$bootstrapEnabled protected
Do bootstrapping or not
Type
bool$classPath protected
The class path for this plugin.
Type
string$configPath protected
The config path for this plugin.
Type
string$consoleEnabled protected
Console middleware
Type
bool$middlewareEnabled protected
Enable middleware
Type
bool$name protected
The name of this plugin
Type
string$path protected
The path to this plugin.
Type
string$routesEnabled protected
Load routes or not
Type
bool
© 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/3.9/class-Cake.Core.BasePlugin.html