1 | <?php |
||
10 | trait Pluggable |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var PluginInterface[] |
||
15 | */ |
||
16 | protected $plugins = []; |
||
17 | |||
18 | /** |
||
19 | * Add a plugin |
||
20 | * @param \Gbowo\Contract\Plugin\PluginInterface $plugin |
||
21 | * @return $this |
||
22 | */ |
||
23 | 43 | public function addPlugin(PluginInterface $plugin) |
|
29 | |||
30 | /** |
||
31 | * Magic method to allow for a plugin call |
||
32 | * @param string $pluginAccessor |
||
33 | * @param array $argument |
||
34 | * @return mixed |
||
35 | */ |
||
36 | 31 | public function __call( |
|
42 | |||
43 | /** |
||
44 | * @param string $accessor The plugin accessor |
||
45 | * @param array $argument Args to pass to the plugin's `handle` method |
||
46 | * @param \Gbowo\Contract\Adapter\AdapterInterface $adapter The adapter in use. |
||
47 | * @throws \LogicException if the plugin does not have an handle method |
||
48 | * @return mixed |
||
49 | */ |
||
50 | 31 | public function callPlugin( |
|
66 | |||
67 | /** |
||
68 | * @param string $accessor |
||
69 | * @return \Gbowo\Contract\Plugin\PluginInterface |
||
70 | * @throws \Gbowo\Exception\PluginNotFoundException If the plugin cannot be found |
||
71 | */ |
||
72 | 31 | public function getPlugin(string $accessor) |
|
82 | } |
||
83 |