1 | <?php |
||
22 | abstract class File |
||
23 | { |
||
24 | /** |
||
25 | * Path to config file. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $filename; |
||
30 | |||
31 | /** |
||
32 | * Path to config file. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $adapters; |
||
37 | |||
38 | /** |
||
39 | * Handling the bootstrapping. |
||
40 | * |
||
41 | * @var \phpbu\App\Configuration\Bootstrapper |
||
42 | 37 | */ |
|
43 | protected $bootstrapper; |
||
44 | 37 | ||
45 | 37 | /** |
|
46 | * File constructor. |
||
47 | * |
||
48 | * @param string $file |
||
49 | * @param \phpbu\App\Configuration\Bootstrapper $bootstrapper |
||
50 | */ |
||
51 | public function __construct(string $file, Configuration\Bootstrapper $bootstrapper) |
||
56 | 32 | ||
57 | 32 | /** |
|
58 | * Returns the phpbu Configuration. |
||
59 | 32 | * |
|
60 | * @param \phpbu\App\Factory $factory |
||
61 | 28 | * @return \phpbu\App\Configuration |
|
62 | 28 | * @throws \phpbu\App\Exception |
|
63 | 26 | */ |
|
64 | public function getConfiguration(AppFactory $factory) |
||
79 | |||
80 | /** |
||
81 | * Load all available config adapters. |
||
82 | * |
||
83 | * @param \phpbu\App\Factory $factory |
||
84 | * @throws \phpbu\App\Exception |
||
85 | */ |
||
86 | protected function setupAdapters(AppFactory $factory) |
||
92 | 2 | ||
93 | /** |
||
94 | * Return a registered adapter. |
||
95 | * |
||
96 | * @param string $name |
||
97 | * @return \phpbu\App\Adapter |
||
98 | * @throws \phpbu\App\Exception |
||
99 | */ |
||
100 | protected function getAdapter($name) |
||
107 | |||
108 | /** |
||
109 | * Return list of adapter configs. |
||
110 | * |
||
111 | * @return array |
||
112 | */ |
||
113 | abstract protected function getAdapterConfigs(); |
||
114 | |||
115 | /** |
||
116 | * Set the phpbu application settings. |
||
117 | * |
||
118 | * @param \phpbu\App\Configuration $configuration |
||
119 | */ |
||
120 | abstract public function setAppSettings(Configuration $configuration); |
||
121 | |||
122 | /** |
||
123 | * Set the log configuration. |
||
124 | * |
||
125 | * @param \phpbu\App\Configuration $configuration |
||
126 | * @throws \phpbu\App\Exception |
||
127 | */ |
||
128 | abstract public function setLoggers(Configuration $configuration); |
||
129 | |||
130 | /** |
||
131 | * Set the backup configurations. |
||
132 | 27 | * |
|
133 | * @param \phpbu\App\Configuration $configuration |
||
134 | 27 | * @throws \phpbu\App\Exception |
|
135 | */ |
||
136 | abstract public function setBackups(Configuration $configuration); |
||
137 | |||
138 | /** |
||
139 | * Handles the bootstrap file inclusion. |
||
140 | * |
||
141 | * @param \phpbu\App\Configuration $configuration |
||
142 | * @throws \phpbu\App\Exception |
||
143 | */ |
||
144 | 28 | protected function handleBootstrap(Configuration $configuration) |
|
148 | 3 | ||
149 | 2 | /** |
|
150 | * Converts a path to an absolute one if necessary. |
||
151 | 28 | * |
|
152 | * @param string $path |
||
153 | * @param boolean $useIncludePath |
||
154 | * @return string |
||
155 | */ |
||
156 | protected function toAbsolutePath($path, $useIncludePath = false) |
||
160 | |||
161 | 37 | /** |
|
162 | * Return option value. |
||
163 | 37 | * Checks if the value should be fetched from an Adapter, if not it just returns the value. |
|
164 | 37 | * |
|
165 | 37 | * @param string $value |
|
166 | * @return string |
||
167 | 37 | * @throws \phpbu\App\Exception |
|
168 | 2 | */ |
|
169 | protected function getAdapterizedValue($value) |
||
178 | |||
179 | /** |
||
180 | * Load the file. |
||
181 | * |
||
182 | * @param string $filename |
||
183 | * @throws \phpbu\App\Exception |
||
184 | * @return \stdClass |
||
185 | */ |
||
186 | protected function loadFile($filename) |
||
197 | } |
||
198 |