Skip to content

Commit 78dfa8f

Browse files
authored
Merge branch 'main' into fix/request-handler-route-wordpress
2 parents f397139 + fcd9dbf commit 78dfa8f

File tree

4 files changed

+55
-21
lines changed

4 files changed

+55
-21
lines changed

src/Roots/Acorn/Application.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Roots\Acorn;
44

5-
use Composer\InstalledVersions;
65
use Exception;
76
use Illuminate\Contracts\Container\BindingResolutionException;
87
use Illuminate\Foundation\Application as FoundationApplication;
@@ -58,7 +57,6 @@ public function __construct($basePath = null)
5857
$this->useEnvironmentPath($this->environmentPath());
5958

6059
$this->registerGlobalHelpers();
61-
$this->registerSupportHelpers();
6260

6361
parent::__construct($basePath);
6462
}
@@ -123,18 +121,6 @@ protected function registerGlobalHelpers()
123121
require_once dirname(__DIR__, 2).'/Illuminate/Foundation/helpers.php';
124122
}
125123

126-
/**
127-
* Load the support helper functions.
128-
*
129-
* @return void
130-
*/
131-
protected function registerSupportHelpers()
132-
{
133-
$path = InstalledVersions::getInstallPath('illuminate/support');
134-
135-
require_once "{$path}/helpers.php";
136-
}
137-
138124
/**
139125
* Set paths that are configurable by the developer.
140126
*

src/Roots/Acorn/Application/Concerns/Bootable.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@
1515
trait Bootable
1616
{
1717
/**
18-
* Boot the application's service providers.
19-
*
20-
* @return $this
18+
* The configuration used to boot the application.
2119
*/
22-
public function bootAcorn()
20+
protected array $bootConfiguration = [];
21+
22+
/**
23+
* Boot the application and handle the request.
24+
*/
25+
public function bootAcorn(array $bootConfiguration = []): static
2326
{
2427
if ($this->isBooted()) {
2528
return $this;
2629
}
2730

31+
$this->bootConfiguration = $bootConfiguration;
32+
2833
if (! defined('LARAVEL_START')) {
2934
define('LARAVEL_START', microtime(true));
3035
}
@@ -236,7 +241,7 @@ protected function registerRequestHandler(
236241
/**
237242
* Handle the request.
238243
*/
239-
public function handleRequest(\Illuminate\Http\Request $request): void
244+
public function handleRequest(Request $request): void
240245
{
241246
$kernel = $this->make(HttpKernelContract::class);
242247

@@ -248,4 +253,12 @@ public function handleRequest(\Illuminate\Http\Request $request): void
248253

249254
exit((int) $response->isServerError());
250255
}
256+
257+
/**
258+
* Retrieve the boot configuration.
259+
*/
260+
public function getBootConfiguration(): array
261+
{
262+
return $this->bootConfiguration;
263+
}
251264
}

src/Roots/Acorn/Configuration/ApplicationBuilder.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class ApplicationBuilder extends FoundationApplicationBuilder
1313
{
1414
use Paths;
1515

16+
/**
17+
* The application builder configuration.
18+
*/
19+
protected array $config = [];
20+
1621
/**
1722
* Register the standard kernel classes for the application.
1823
*
@@ -81,6 +86,17 @@ public function withRouting(?Closure $using = null,
8186
$this->app->handleWordPressRequests();
8287
}
8388

89+
$this->config['routing'] = [
90+
'web' => $web,
91+
'api' => $api,
92+
'commands' => $commands,
93+
'channels' => $channels,
94+
'pages' => $pages,
95+
'health' => $health,
96+
'apiPrefix' => $apiPrefix,
97+
'wordpress' => $wordpress,
98+
];
99+
84100
return $this;
85101
}
86102

@@ -126,6 +142,11 @@ public function withProviders(array $providers = [], bool $withBootstrapProvider
126142
: null
127143
);
128144

145+
$this->config['providers'] = [
146+
...$this->config['providers'] ?? [],
147+
...$providers,
148+
];
149+
129150
return $this;
130151
}
131152

@@ -146,6 +167,6 @@ public function create()
146167
*/
147168
public function boot()
148169
{
149-
return $this->app->bootAcorn();
170+
return $this->app->bootAcorn($this->config);
150171
}
151172
}

src/Roots/Acorn/Console/Concerns/GetsFreshApplication.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,23 @@ protected function getFreshApplication()
1515
{
1616
$application = get_class($app = Application::getInstance());
1717

18+
$config = $app->getBootConfiguration();
19+
20+
$routing = $config['routing'] ?? [];
21+
1822
return $application::configure($app->basePath())
1923
->withPaths(...$this->getApplicationPaths($app))
20-
->withRouting()
24+
->withProviders($config['providers'] ?? [])
25+
->withRouting(
26+
web: $routing['web'] ?? null,
27+
api: $routing['api'] ?? null,
28+
commands: $routing['commands'] ?? null,
29+
channels: $routing['channels'] ?? null,
30+
pages: $routing['pages'] ?? null,
31+
health: $routing['health'] ?? null,
32+
apiPrefix: $routing['apiPrefix'] ?? 'api',
33+
wordpress: $routing['wordpress'] ?? false,
34+
)
2135
->boot();
2236
}
2337

0 commit comments

Comments
 (0)