1 | <?php |
||
14 | class ConfigServiceProvider implements ServiceProviderInterface |
||
15 | { |
||
16 | /** |
||
17 | * Configuration instance |
||
18 | * |
||
19 | * @var Registry |
||
20 | * @since 1.0 |
||
21 | */ |
||
22 | private $config; |
||
23 | |||
24 | /** |
||
25 | * Constructor. |
||
26 | * |
||
27 | * @param string $file Path to the config file. |
||
28 | * |
||
29 | * @since 1.0 |
||
30 | * @throws \RuntimeException |
||
31 | */ |
||
32 | 2 | public function __construct($file) |
|
33 | { |
||
34 | // Verify the configuration exists and is readable. |
||
35 | 2 | if (!is_readable($file)) |
|
36 | 2 | { |
|
37 | 1 | throw new \RuntimeException('Configuration file does not exist or is unreadable.'); |
|
38 | } |
||
39 | |||
40 | 1 | $this->config = (new Registry)->loadFile($file); |
|
41 | 1 | } |
|
42 | |||
43 | /** |
||
44 | * Registers the service provider with a DI container. |
||
45 | * |
||
46 | * @param Container $container The DI container. |
||
47 | * |
||
48 | * @return void |
||
49 | * |
||
50 | * @since 1.0 |
||
51 | */ |
||
52 | 1 | public function register(Container $container) |
|
63 | } |
||
64 |