From 87412efcf7e7643e2ff44271c37a30f6c18e87cf Mon Sep 17 00:00:00 2001 From: Jacob Baker-Kretzmar Date: Fri, 11 Nov 2022 12:45:38 -0500 Subject: [PATCH] Rename `bootstrap` to `bootstrapWith` and make it take an array of bootstrapper classes --- jigsaw | 2 +- src/Container.php | 17 ++++++++++------- tests/TestCase.php | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/jigsaw b/jigsaw index e974f95c..b977bbe3 100755 --- a/jigsaw +++ b/jigsaw @@ -7,7 +7,7 @@ require __DIR__ . '/vendor/autoload.php'; $app = new TightenCo\Jigsaw\Container; -$app->bootstrap(); +$app->bootstrapWith([]); $application = new Symfony\Component\Console\Application('Jigsaw', '1.4.0'); $application->add($app[TightenCo\Jigsaw\Console\InitCommand::class]); diff --git a/src/Container.php b/src/Container.php index 831b05f6..1e18dbc1 100644 --- a/src/Container.php +++ b/src/Container.php @@ -35,16 +35,19 @@ public function __construct() $this->registerCoreAliases(); } - public function bootstrap(): void + public function bootstrapWith(array $bootstrappers): void { - if (! $this->bootstrapped) { - $this->bootstrapped = true; + $this->bootstrapped = true; - $this->loadEnvironmentVariables(); - $this->loadConfiguration(); - $this->registerConfiguredProviders(); - $this->boot(); + $this->loadEnvironmentVariables(); + $this->loadConfiguration(); + + foreach ($bootstrappers as $bootstrapper) { + $this->make($bootstrapper)->bootstrap($this); } + + $this->registerConfiguredProviders(); + $this->boot(); } public function path(string ...$path): string diff --git a/tests/TestCase.php b/tests/TestCase.php index 23493a58..bc7baca1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -27,7 +27,7 @@ protected function setUp(): void parent::setUp(); $this->app = new Container; - $this->app->bootstrap(); + $this->app->bootstrapWith([]); $this->app->buildPath = [ 'source' => $this->sourcePath,