@@ 5-33 (lines=29) @@ | ||
2 | ||
3 | namespace Rudolf\Component\Modules; |
|
4 | ||
5 | class Hooks |
|
6 | { |
|
7 | /** |
|
8 | * @var array |
|
9 | */ |
|
10 | private $modules; |
|
11 | ||
12 | /** |
|
13 | * @var string |
|
14 | */ |
|
15 | private $path; |
|
16 | ||
17 | public function __construct(array $modules, $path = '/modules') |
|
18 | { |
|
19 | $this->modules = $modules; |
|
20 | $this->path = $path; |
|
21 | } |
|
22 | ||
23 | public function addHooks() |
|
24 | { |
|
25 | foreach ($this->modules as $key => $value) { |
|
26 | $file = $this->path.'/'.$value->getName().'/hooks.php'; |
|
27 | ||
28 | if (is_file($file)) { |
|
29 | include $file; |
|
30 | } |
|
31 | } |
|
32 | } |
|
33 | } |
|
34 |
@@ 5-39 (lines=35) @@ | ||
2 | ||
3 | namespace Rudolf\Component\Plugins; |
|
4 | ||
5 | class Hooks |
|
6 | { |
|
7 | /** |
|
8 | * @var array |
|
9 | */ |
|
10 | private $plugins; |
|
11 | ||
12 | /** |
|
13 | * @var string |
|
14 | */ |
|
15 | private $path; |
|
16 | ||
17 | /** |
|
18 | * Hooks constructor. |
|
19 | * |
|
20 | * @param array $plugins |
|
21 | * @param $path |
|
22 | */ |
|
23 | public function __construct(array $plugins, $path) |
|
24 | { |
|
25 | $this->plugins = $plugins; |
|
26 | $this->path = $path; |
|
27 | } |
|
28 | ||
29 | public function addHooks() |
|
30 | { |
|
31 | foreach ($this->plugins as $key => $value) { |
|
32 | $file = $this->path.'/'.$value->getName().'/hooks.php'; |
|
33 | ||
34 | if (is_file($file)) { |
|
35 | include $file; |
|
36 | } |
|
37 | } |
|
38 | } |
|
39 | } |
|
40 |