Skip to content

Commit

Permalink
NEW NullDatabase (silverstripe#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 <unclecheese@leftandmain.com>
Co-authored-by: Maxime Rainville <maxime@silverstripe.com>
  • Loading branch information
3 people authored and GuySartorelli committed Jul 6, 2022
1 parent 9a600bb commit 52e074e
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 52e074e

Please sign in to comment.