| @@ 18-38 (lines=21) @@ | ||
| 15 | * @link http://phpbu.de/ |
|
| 16 | * @since Class available since Release 5.0.8 |
|
| 17 | */ |
|
| 18 | class Bootstrapper |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * Execute bootstrap runner. |
|
| 22 | * |
|
| 23 | * @param \phpbu\App\Configuration $configuration |
|
| 24 | * @throws \phpbu\App\Exception |
|
| 25 | */ |
|
| 26 | public function run(Configuration $configuration) |
|
| 27 | { |
|
| 28 | $filename = $configuration->getBootstrap(); |
|
| 29 | ||
| 30 | if (!empty($filename)) { |
|
| 31 | $pathToFile = stream_resolve_include_path($filename); |
|
| 32 | if (!$pathToFile || !is_readable($pathToFile)) { |
|
| 33 | throw new Exception(sprintf('Cannot open bootstrap file "%s".' . PHP_EOL, $filename)); |
|
| 34 | } |
|
| 35 | require $pathToFile; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 18-49 (lines=32) @@ | ||
| 15 | * @link http://phpbu.de/ |
|
| 16 | * @since Class available since Release 3.0.0 |
|
| 17 | */ |
|
| 18 | class Bootstrap extends Abstraction |
|
| 19 | { |
|
| 20 | /** |
|
| 21 | * Execute bootstrap runner. |
|
| 22 | * |
|
| 23 | * @param \phpbu\App\Configuration $configuration |
|
| 24 | * @throws \phpbu\App\Exception |
|
| 25 | */ |
|
| 26 | public function run(Configuration $configuration) |
|
| 27 | { |
|
| 28 | $this->handleBootstrap($configuration); |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Handles the bootstrap file inclusion. |
|
| 33 | * |
|
| 34 | * @param \phpbu\App\Configuration $configuration |
|
| 35 | * @throws \phpbu\App\Exception |
|
| 36 | */ |
|
| 37 | protected function handleBootstrap(Configuration $configuration) |
|
| 38 | { |
|
| 39 | $filename = $configuration->getBootstrap(); |
|
| 40 | ||
| 41 | if (!empty($filename)) { |
|
| 42 | $pathToFile = stream_resolve_include_path($filename); |
|
| 43 | if (!$pathToFile || !is_readable($pathToFile)) { |
|
| 44 | throw new Exception(sprintf('Cannot open bootstrap file "%s".' . PHP_EOL, $filename)); |
|
| 45 | } |
|
| 46 | require $pathToFile; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||