@@ 5-65 (lines=61) @@ | ||
2 | ||
3 | namespace Rudolf\Component\Modules; |
|
4 | ||
5 | class Module |
|
6 | { |
|
7 | /** |
|
8 | * @var string |
|
9 | */ |
|
10 | private $name; |
|
11 | ||
12 | /** |
|
13 | * @var int |
|
14 | */ |
|
15 | private $status; |
|
16 | ||
17 | /** |
|
18 | * Module constructor. |
|
19 | * |
|
20 | * @param $name |
|
21 | * @param int $status |
|
22 | * |
|
23 | * @throws \InvalidArgumentException |
|
24 | */ |
|
25 | public function __construct($name, $status = 1) |
|
26 | { |
|
27 | $this->name = $name; |
|
28 | $this->status = $status; |
|
29 | ||
30 | if (empty($name)) { |
|
31 | throw new \InvalidArgumentException('Invalid module name'); |
|
32 | } |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * @return string |
|
37 | */ |
|
38 | public function getName() |
|
39 | { |
|
40 | return $this->name; |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * @return bool |
|
45 | */ |
|
46 | public function getStatus() |
|
47 | { |
|
48 | return (bool) $this->status; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @return array |
|
53 | * @throws \Exception |
|
54 | */ |
|
55 | public function getConfig() |
|
56 | { |
|
57 | $file = CONFIG_ROOT.'/modules/'.strtolower($this->name).'.php'; |
|
58 | ||
59 | if (!file_exists($file)) { |
|
60 | throw new \Exception("{$this->name} module configuration does not exist"); |
|
61 | } |
|
62 | ||
63 | return include $file; |
|
64 | } |
|
65 | } |
|
66 |
@@ 5-66 (lines=62) @@ | ||
2 | ||
3 | namespace Rudolf\Component\Plugins; |
|
4 | ||
5 | class Plugin |
|
6 | { |
|
7 | /** |
|
8 | * @var string |
|
9 | */ |
|
10 | private $name; |
|
11 | ||
12 | /** |
|
13 | * @var int |
|
14 | */ |
|
15 | private $status; |
|
16 | ||
17 | /** |
|
18 | * Plugin constructor. |
|
19 | * |
|
20 | * @param $name |
|
21 | * @param int $status |
|
22 | * |
|
23 | * @throws \InvalidArgumentException |
|
24 | */ |
|
25 | public function __construct($name, $status = 1) |
|
26 | { |
|
27 | $this->name = $name; |
|
28 | $this->status = $status; |
|
29 | ||
30 | if (empty($name)) { |
|
31 | throw new \InvalidArgumentException('Invalid plugin name'); |
|
32 | } |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * @return string |
|
37 | */ |
|
38 | public function getName() |
|
39 | { |
|
40 | return $this->name; |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * @return bool |
|
45 | */ |
|
46 | public function getStatus() |
|
47 | { |
|
48 | return (bool) $this->status; |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * @return array |
|
53 | * |
|
54 | * @throws \Exception |
|
55 | */ |
|
56 | public function getConfig() |
|
57 | { |
|
58 | $file = CONFIG_ROOT.'/plugins/'.strtolower($this->name).'.php'; |
|
59 | ||
60 | if (!file_exists($file)) { |
|
61 | throw new \Exception("{$this->name} plugin configuration does not exist"); |
|
62 | } |
|
63 | ||
64 | return include $file; |
|
65 | } |
|
66 | } |
|
67 |