-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
41 lines (33 loc) · 1.06 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
use SilverStripe\Control\CLIRequestBuilder;
use SilverStripe\Core\DatabaselessKernel;
use SilverStripe\Core\Environment;
use SilverStripe\ORM\Connect\NullDatabase;
use SilverStripe\ORM\DB;
// Add Page/PageController stubs which may be required
if (!class_exists(Page::class)) {
require __DIR__ . '/stubs/Page.php';
}
if (!class_exists(PageController::class)) {
require __DIR__ . '/stubs/PageController.php';
}
// We don't need access to the database
DB::set_conn(new NullDatabase());
// Ensure that the proper globals are set
$globalVars = Environment::getVariables();
$globalVars['_SERVER']['REQUEST_URI'] = '';
$globalVars = CLIRequestBuilder::cleanEnvironment($globalVars);
Environment::setVariables($globalVars);
// Mock a Silverstripe application in order to access the Configuration API
try {
$kernel = new class(BASE_PATH) extends DatabaselessKernel {
protected function getIncludeTests()
{
return true;
}
};
$kernel->boot();
} catch (Throwable $e) {
echo $e->getMessage();
}