forked from silverstripe/silverstripe-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW DatabaselessKernel to support operation without DB
This is required for GraphQL code generation in CI (without a working runtime database/webserver environment). Context: silverstripe/silverstripe-graphql#388
- Loading branch information
Showing
4 changed files
with
385 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Core; | ||
|
||
use SilverStripe\EventDispatcher\Dispatch\Dispatcher; | ||
use SilverStripe\EventDispatcher\Event\EventContextInterface; | ||
use SilverStripe\EventDispatcher\Event\EventHandlerInterface; | ||
use SilverStripe\ORM\Connect\NullDatabase; | ||
use SilverStripe\ORM\DB; | ||
|
||
/** | ||
* Boot a kernel without requiring a database connection. | ||
* This is a workaround for the lack of composition in the boot stages | ||
* of CoreKernel, as well as for the framework's misguided assumptions | ||
* around the availability of a database for every execution path. | ||
* | ||
* @internal | ||
*/ | ||
class DatabaselessKernel extends CoreKernel | ||
{ | ||
protected $queryErrorMessage = 'Booted with DatabaseLessKernel, cannot execute query: %s'; | ||
|
||
/** | ||
* Allows disabling of the configured error handling. | ||
* This can be useful to ensure the execution context (e.g. composer) | ||
* can consistently use its own error handling. | ||
* | ||
* @var boolean | ||
*/ | ||
protected $bootErrorHandling = true; | ||
|
||
public function setBootErrorHandling(bool $bool) | ||
{ | ||
$this->bootErrorHandling = $bool; | ||
return $this; | ||
} | ||
|
||
public function boot($flush = false) | ||
{ | ||
$this->flush = $flush; | ||
|
||
$this->bootPHP(); | ||
$this->bootManifests($flush); | ||
|
||
if ($this->bootErrorHandling) { | ||
$this->bootErrorHandling(); | ||
} | ||
|
||
$this->bootConfigs(); | ||
|
||
$this->booted = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.