Passed
Push — 4 ( 3b5c72...d8499a )
by Steve
07:17
created

DatabaselessKernel::isFlushed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace SilverStripe\Core;
4
5
use Exception;
6
7
/**
8
 * Boot a kernel without requiring a database connection.
9
 * This is a workaround for the lack of composition in the boot stages
10
 * of CoreKernel, as well as for the framework's misguided assumptions
11
 * around the availability of a database for every execution path.
12
 *
13
 * @internal
14
 */
15
class DatabaselessKernel extends BaseKernel
16
{
17
    /**
18
     * Indicates whether the Kernel has been flushed on boot
19
     * Uninitialised before boot
20
     *
21
     * @var bool
22
     */
23
    private $flush;
24
25
    /**
26
     * Allows disabling of the configured error handling.
27
     * This can be useful to ensure the execution context (e.g. composer)
28
     * can consistently use its own error handling.
29
     *
30
     * @var boolean
31
     */
32
    protected $bootErrorHandling = true;
33
34
    public function setBootErrorHandling(bool $bool)
35
    {
36
        $this->bootErrorHandling = $bool;
37
        return $this;
38
    }
39
40
    /**
41
     * @param false $flush
42
     * @throws Exception
43
     */
44
    public function boot($flush = false)
45
    {
46
        $this->flush = $flush;
47
48
        $this->bootPHP();
49
        $this->bootManifests($flush);
50
        $this->bootErrorHandling();
51
        $this->bootConfigs();
52
53
        $this->setBooted(true);
54
    }
55
56
    /**
57
     * @return bool
58
     */
59
    public function isFlushed()
60
    {
61
        return $this->flush;
62
    }
63
}
64