Passed
Pull Request — 4 (#10016)
by
unknown
06:46
created

DatabaselessKernel::setBootErrorHandling()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace SilverStripe\Core;
4
5
/**
6
 * Boot a kernel without requiring a database connection.
7
 * This is a workaround for the lack of composition in the boot stages
8
 * of CoreKernel, as well as for the framework's misguided assumptions
9
 * around the availability of a database for every execution path.
10
 *
11
 * @internal
12
 */
13
class DatabaselessKernel extends CoreKernel
14
{
15
    protected $queryErrorMessage = 'Booted with DatabaseLessKernel, cannot execute query: %s';
16
17
    /**
18
     * Allows disabling of the configured error handling.
19
     * This can be useful to ensure the execution context (e.g. composer)
20
     * can consistently use its own error handling.
21
     *
22
     * @var boolean
23
     */
24
    protected $bootErrorHandling = true;
25
26
    public function setBootErrorHandling(bool $bool)
27
    {
28
        $this->bootErrorHandling = $bool;
29
        return $this;
30
    }
31
32
    public function boot($flush = false)
33
    {
34
        $this->flush = $flush;
0 ignored issues
show
Bug introduced by
The property flush is declared private in SilverStripe\Core\CoreKernel and cannot be accessed from this context.
Loading history...
35
36
        $this->bootPHP();
37
        $this->bootManifests($flush);
38
39
        if ($this->bootErrorHandling) {
40
            $this->bootErrorHandling();
41
        }
42
43
        $this->bootConfigs();
44
45
        $this->booted = true;
0 ignored issues
show
Bug introduced by
The property booted is declared private in SilverStripe\Core\CoreKernel and cannot be accessed from this context.
Loading history...
46
    }
47
}
48