1 | <?php |
||
2 | |||
3 | namespace SilverStripe\Core; |
||
4 | |||
5 | use SilverStripe\EventDispatcher\Dispatch\Dispatcher; |
||
6 | use SilverStripe\EventDispatcher\Event\EventContextInterface; |
||
7 | use SilverStripe\EventDispatcher\Event\EventHandlerInterface; |
||
8 | use SilverStripe\ORM\Connect\NullDatabase; |
||
9 | use SilverStripe\ORM\DB; |
||
10 | |||
11 | /** |
||
12 | * Boot a kernel without requiring a database connection. |
||
13 | * This is a workaround for the lack of composition in the boot stages |
||
14 | * of CoreKernel, as well as for the framework's misguided assumptions |
||
15 | * around the availability of a database for every execution path. |
||
16 | * |
||
17 | * @internal |
||
18 | */ |
||
19 | class DatabaselessKernel extends CoreKernel |
||
20 | { |
||
21 | protected $queryErrorMessage = 'Booted with DatabaseLessKernel, cannot execute query: %s'; |
||
22 | |||
23 | /** |
||
24 | * Allows disabling of the configured error handling. |
||
25 | * This can be useful to ensure the execution context (e.g. composer) |
||
26 | * can consistently use its own error handling. |
||
27 | * |
||
28 | * @var boolean |
||
29 | */ |
||
30 | protected $bootErrorHandling = true; |
||
31 | |||
32 | public function setBootErrorHandling(bool $bool) |
||
33 | { |
||
34 | $this->bootErrorHandling = $bool; |
||
35 | return $this; |
||
36 | } |
||
37 | |||
38 | public function boot($flush = false) |
||
39 | { |
||
40 | $this->flush = $flush; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
41 | |||
42 | $this->bootPHP(); |
||
43 | $this->bootManifests($flush); |
||
44 | |||
45 | if ($this->bootErrorHandling) { |
||
46 | $this->bootErrorHandling(); |
||
47 | } |
||
48 | |||
49 | $this->bootConfigs(); |
||
50 | |||
51 | $this->booted = true; |
||
0 ignored issues
–
show
|
|||
52 | } |
||
53 | } |
||
54 |