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) |
|
52 | |||
53 | /** |
||
54 | * Invoked after the entire route has been handled. |
||
55 | * @param AbstractHandler $handler The handler selected by the router. |
||
56 | */ |
||
57 | 1 | public function afterFullRouteInvoked(AbstractHandler $handler) |
|
60 | |||
61 | /** |
||
62 | * Invoked if an exception is thrown during the route. |
||
63 | * @param AbstractHandler $handler The handler selected by the router. |
||
64 | * @param Exception $exception The exception that was thrown. |
||
65 | */ |
||
66 | 1 | public function errorOccurred(AbstractHandler $handler, Exception $exception) |
|
69 | |||
70 | /** |
||
71 | * Returns a sortable number for sorting plugins by execution priority. A lower number indicates |
||
72 | * higher priority. |
||
73 | * @return integer The execution priority (as a number). |
||
74 | */ |
||
75 | 7 | public function getExecutionOrder() |
|
79 | |||
80 | /** |
||
81 | * Sets the controller/action whitelist of this particular plugin. Note that |
||
82 | * setting a whitelist will remove any previously set blacklists. |
||
83 | * @param array $whitelist The controller/action whitelist. |
||
84 | * @return AbstractPlugin Returns $this. |
||
85 | */ |
||
86 | 2 | public function setWhitelist($whitelist) |
|
91 | |||
92 | /** |
||
93 | * Sets the controller/action blacklist of this particular plugin. Note that |
||
94 | * setting a blacklist will remove any previously set whitelists. |
||
95 | * @param array $blacklist The controller/action blacklist. |
||
96 | * @return AbstractPlugin Returns $this. |
||
97 | */ |
||
98 | 1 | public function setBlacklist($blacklist) |
|
103 | |||
104 | /** |
||
105 | * Returns whether or not the given controller and action requested should |
||
106 | * invoke this plugin. |
||
107 | * @param string $controller The requested controller. |
||
108 | * @param string $action The requested action. |
||
109 | * @return boolean Returns true if the given plugin is allowed to run against |
||
110 | * this controller/action and false otherwise. |
||
111 | */ |
||
112 | 2 | public function supportsControllerAndAction($controller, $action) |
|
140 | |||
141 | /** |
||
142 | * Retrieve an element from the DI container. |
||
143 | * @param string $key The DI key. |
||
144 | * @param boolean $useCache (optional) An optional indicating whether we |
||
145 | * should use the cached version of the element (true by default). |
||
146 | * @return mixed Returns the DI element mapped to that key. |
||
147 | */ |
||
148 | 2 | public function get($key, $useCache = true) |
|
152 | |||
153 | /** |
||
154 | * Sets an element in the DI container for the specified key. |
||
155 | * @param string $key The DI key. |
||
156 | * @param mixed $element The DI element to store. |
||
157 | * @return Di Returns the Di instance. |
||
158 | */ |
||
159 | 1 | public function set($key, $element) |
|
163 | } |
||
164 |