Class BasePlugin
Base Plugin Class
Every plugin should extend from this class or implement the interfaces and include a plugin class in its src root folder.
Constants
- 
          
          array<string>VALID_HOOKS ¶['bootstrap', 'console', 'middleware', 'routes', 'services']List of valid hooks. 
Property Summary
- 
        $bootstrapEnabled protectedboolDo bootstrapping or not 
- 
        $classPath protectedstringThe class path for this plugin. 
- 
        $configPath protectedstringThe config path for this plugin. 
- 
        $consoleEnabled protectedboolConsole middleware 
- 
        $middlewareEnabled protectedboolEnable middleware 
- 
        $name protectedstringThe name of this plugin 
- 
        $path protectedstringThe path to this plugin. 
- 
        $routesEnabled protectedboolLoad routes or not 
- 
        $servicesEnabled protectedboolRegister container services 
- 
        $templatePath protectedstringThe templates path for this plugin. 
Method Summary
- 
          __construct() publicConstructor 
- 
          bootstrap() publicLoad all the application configuration and bootstrap logic. 
- 
          checkHook() protectedCheck if a hook name is valid 
- 
          console() publicAdd console commands for the plugin. 
- 
          disable() publicDisables the named hook 
- 
          enable() publicEnables the named hook 
- 
          getClassPath() publicGet the filesystem path to configuration for this plugin 
- 
          getConfigPath() publicGet the filesystem path to configuration for this plugin 
- 
          getName() publicGet the name of this plugin. 
- 
          getPath() publicGet the filesystem path to this plugin 
- 
          getTemplatePath() publicGet the filesystem path to templates for this plugin 
- 
          initialize() publicInitialization hook called from constructor. 
- 
          isEnabled() publicCheck if the named hook is enabled 
- 
          middleware() publicAdd middleware for the plugin. 
- 
          routes() publicAdd routes for the plugin. 
- 
          services() publicRegister container services for this plugin. 
Method Detail
__construct() ¶ public
__construct(array<string, mixed> $options = [])Constructor
Parameters
- 
                array<string, mixed>$options optional
- Options 
bootstrap() ¶ public
bootstrap(Cake\Core\PluginApplicationInterface $app): voidLoad 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
Returns
voidcheckHook() ¶ protected
checkHook(string $hook): voidCheck if a hook name is valid
Parameters
- 
                string$hook
- The hook name to check 
Returns
voidThrows
InvalidArgumentExceptionon invalid hooks
console() ¶ public
console(Cake\Console\CommandCollection $commands): Cake\Console\CommandCollectionAdd console commands for the plugin.
Parameters
- 
                Cake\Console\CommandCollection$commands
Returns
Cake\Console\CommandCollectiondisable() ¶ public
disable(string $hook): $thisDisables the named hook
Parameters
- 
                string$hook
Returns
$thisenable() ¶ public
enable(string $hook): $thisEnables the named hook
Parameters
- 
                string$hook
Returns
$thisgetClassPath() ¶ public
getClassPath(): stringGet the filesystem path to configuration for this plugin
Returns
stringgetConfigPath() ¶ public
getConfigPath(): stringGet the filesystem path to configuration for this plugin
Returns
stringgetTemplatePath() ¶ public
getTemplatePath(): stringGet the filesystem path to templates for this plugin
Returns
stringisEnabled() ¶ public
isEnabled(string $hook): boolCheck if the named hook is enabled
Parameters
- 
                string$hook
Returns
boolmiddleware() ¶ public
middleware(Cake\Http\MiddlewareQueue $middlewareQueue): Cake\Http\MiddlewareQueueAdd middleware for the plugin.
Parameters
- 
                Cake\Http\MiddlewareQueue$middlewareQueue
Returns
Cake\Http\MiddlewareQueueroutes() ¶ public
routes(Cake\Routing\RouteBuilder $routes): voidAdd 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
Returns
voidservices() ¶ public
services(Cake\Core\ContainerInterface $container): voidRegister container services for this plugin.
Parameters
- 
                Cake\Core\ContainerInterface$container
- The container to add services to. 
Returns
void