| 1 | <?php |
||
| 12 | class MethodPluginManager { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Get the Method plugins. |
||
| 16 | * |
||
| 17 | * @return array |
||
| 18 | */ |
||
| 19 | 12 | public function getPlugins() { |
|
| 20 | 12 | $candidates = array_filter( |
|
| 21 | 12 | ClassFinder::getClassesInNamespace('drupol\Yaroc\Plugin\Method'), |
|
| 22 | 12 | function ($className) { |
|
| 23 | 12 | return in_array('drupol\Yaroc\Plugin\MethodPluginInterface', class_implements($className)); |
|
| 24 | 12 | } |
|
| 25 | ); |
||
| 26 | |||
| 27 | 12 | $classes = []; |
|
| 28 | 12 | foreach ($candidates as $candidate) { |
|
| 29 | 12 | $candidate = new \ReflectionClass($candidate); |
|
| 30 | 12 | $candidate = $candidate->newInstance(); |
|
| 31 | |||
| 32 | 12 | $classes[$candidate::METHOD] = $candidate; |
|
| 33 | } |
||
| 34 | |||
| 35 | 12 | return $classes; |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get a specific Method plugin. |
||
| 40 | * |
||
| 41 | * @param string $methodName |
||
| 42 | * |
||
| 43 | * @return MethodPluginInterface|bool |
||
| 44 | */ |
||
| 45 | 12 | public function getPlugin($methodName) { |
|
| 54 | |||
| 55 | } |
||
| 56 |