1 | <?php |
||
18 | abstract class AbstractPlugin implements PluginInterface, DiProviderInterface |
||
19 | { |
||
20 | /** the default priority of a plugin */ |
||
21 | const PRIORITY_DEFAULT = 1000; |
||
22 | |||
23 | /** A string constant indicating the whitelist/blacklist applies to all |
||
24 | actions within a controller */ |
||
25 | const ALL_ACTIONS = 'all'; |
||
26 | |||
27 | /** The plugin options */ |
||
28 | protected $options; |
||
29 | |||
30 | // properties for plugin/service compatibility |
||
31 | // both properties cannot be set at the same time (one or the other or both |
||
32 | // must be null at any point) |
||
33 | private $whitelist; |
||
34 | private $blacklist; |
||
35 | |||
36 | /** |
||
37 | * Constructor for the plugin. |
||
38 | * @param array $options The array of options. |
||
39 | */ |
||
40 | 19 | public function __construct($options) |
|
44 | |||
45 | /** |
||
46 | * Invoked directly after the router decides which handler will be used. |
||
47 | * @param AbstractHandler $handler The handler selected by the router. |
||
48 | */ |
||
49 | 13 | public function afterHandlerSelected(AbstractHandler $handler) |
|
50 | { |
||
51 | |||
52 | 13 | } |
|
53 | |||
54 | /** |
||
55 | * Invoked after the entire route has been handled. |
||
56 | * @param AbstractHandler $handler The handler selected by the router. |
||
57 | */ |
||
58 | 1 | public function afterFullRouteInvoked(AbstractHandler $handler) |
|
62 | |||
63 | /** |
||
64 | * Invoked if an exception is thrown during the route. |
||
65 | * @param AbstractHandler $handler The handler selected by the router. |
||
66 | * @param Exception $exception The exception that was thrown. |
||
67 | */ |
||
68 | 1 | public function errorOccurred(AbstractHandler $handler, Exception $exception) |
|
72 | |||
73 | /** |
||
74 | * Returns a sortable number for sorting plugins by execution priority. A lower number indicates |
||
75 | * higher priority. |
||
76 | * @return integer The execution priority (as a number). |
||
77 | */ |
||
78 | 7 | public function getExecutionOrder() |
|
82 | |||
83 | /** |
||
84 | * Sets the controller/action whitelist of this particular plugin. Note that |
||
85 | * setting a whitelist will remove any previously set blacklists. |
||
86 | * @param array $whitelist The controller/action whitelist. |
||
87 | * @return AbstractPlugin Returns $this. |
||
88 | */ |
||
89 | 2 | public function setWhitelist($whitelist) |
|
94 | |||
95 | /** |
||
96 | * Sets the controller/action blacklist of this particular plugin. Note that |
||
97 | * setting a blacklist will remove any previously set whitelists. |
||
98 | * @param array $blacklist The controller/action blacklist. |
||
99 | * @return AbstractPlugin Returns $this. |
||
100 | */ |
||
101 | 1 | public function setBlacklist($blacklist) |
|
106 | |||
107 | /** |
||
108 | * Returns whether or not the given controller and action requested should |
||
109 | * invoke this plugin. |
||
110 | * @param string $controller The requested controller. |
||
111 | * @param string $action The requested action. |
||
112 | * @return boolean Returns true if the given plugin is allowed to run against |
||
113 | * this controller/action and false otherwise. |
||
114 | */ |
||
115 | 2 | public function supportsControllerAndAction($controller, $action) |
|
143 | |||
144 | /** |
||
145 | * Retrieve an element from the DI container. |
||
146 | * @param string $key The DI key. |
||
147 | * @param boolean $useCache (optional) An optional indicating whether we |
||
148 | * should use the cached version of the element (true by default). |
||
149 | * @return mixed Returns the DI element mapped to that key. |
||
150 | */ |
||
151 | 2 | public function get($key, $useCache = true) |
|
155 | |||
156 | /** |
||
157 | * Sets an element in the DI container for the specified key. |
||
158 | * @param string $key The DI key. |
||
159 | * @param mixed $element The DI element to store. |
||
160 | * @return Di Returns the Di instance. |
||
161 | */ |
||
162 | 1 | public function set($key, $element) |
|
166 | } |
||
167 |