Skip to content

Commit

Permalink
NEW NullDatabase (#10016)
Browse files Browse the repository at this point in the history
* 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

* New --no-database option for sake

* Refactor to abstract class

* Apply feedback peer review

Co-authored-by: Aaron Carlino <[email protected]>
Co-authored-by: Maxime Rainville <[email protected]>
  • Loading branch information
3 people authored Feb 3, 2022
1 parent 3b5c72f commit d8499a2
Show file tree
Hide file tree
Showing 6 changed files with 949 additions and 493 deletions.
14 changes: 13 additions & 1 deletion cli-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
use SilverStripe\Control\CLIRequestBuilder;
use SilverStripe\Control\HTTPApplication;
use SilverStripe\Core\CoreKernel;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Connect\NullDatabase;
use SilverStripe\Core\DatabaselessKernel;

require __DIR__ . '/src/includes/autoload.php';

Expand All @@ -16,8 +19,17 @@
// Build request and detect flush
$request = CLIRequestBuilder::createFromEnvironment();


$skipDatabase = in_array('--no-database', $argv);
if ($skipDatabase) {
DB::set_conn(new NullDatabase());
}
// Default application
$kernel = new CoreKernel(BASE_PATH);
$kernel = $skipDatabase
? new DatabaselessKernel(BASE_PATH)
: new CoreKernel(BASE_PATH);

$app = new HTTPApplication($kernel);
$response = $app->handle($request);

$response->output();
Loading

0 comments on commit d8499a2

Please sign in to comment.