-
Notifications
You must be signed in to change notification settings - Fork 6
/
PluginInterface.php
135 lines (120 loc) · 3.7 KB
/
PluginInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (https://cakefoundation.org)
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.6.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Core;
use Cake\Console\CommandCollection;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\RouteBuilder;
/**
* Plugin Interface
*
* @method void services(\Cake\Core\ContainerInterface $container) Register plugin services to
* the application's container
*/
interface PluginInterface
{
/**
* List of valid hooks.
*
* @var string[]
*/
public const VALID_HOOKS = ['bootstrap', 'console', 'middleware', 'routes', 'services'];
/**
* Get the name of this plugin.
*
* @return string
*/
public function getName(): string;
/**
* Get the filesystem path to this plugin
*
* @return string
*/
public function getPath(): string;
/**
* Get the filesystem path to configuration for this plugin
*
* @return string
*/
public function getConfigPath(): string;
/**
* Get the filesystem path to configuration for this plugin
*
* @return string
*/
public function getClassPath(): string;
/**
* Get the filesystem path to templates for this plugin
*
* @return string
*/
public function getTemplatePath(): string;
/**
* 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.
*
* @param \Cake\Core\PluginApplicationInterface $app The host application
* @return void
*/
public function bootstrap(PluginApplicationInterface $app): void;
/**
* Add console commands for the plugin.
*
* @param \Cake\Console\CommandCollection $commands The command collection to update
* @return \Cake\Console\CommandCollection
*/
public function console(CommandCollection $commands): CommandCollection;
/**
* Add middleware for the plugin.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update.
* @return \Cake\Http\MiddlewareQueue
*/
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue;
/**
* 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.
*
* @param \Cake\Routing\RouteBuilder $routes The route builder to update.
* @return void
*/
public function routes(RouteBuilder $routes): void;
/**
* Disables the named hook
*
* @param string $hook The hook to disable
* @return $this
*/
public function disable(string $hook);
/**
* Enables the named hook
*
* @param string $hook The hook to disable
* @return $this
*/
public function enable(string $hook);
/**
* Check if the named hook is enabled
*
* @param string $hook The hook to check
* @return bool
*/
public function isEnabled(string $hook): bool;
}