Skip to content

Commit

Permalink
Fix L10 install (it also has a bootstrap/app.php)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Mar 6, 2024
1 parent 7b64873 commit 8036369
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,21 @@ private function installMiddlewareAfter($after, $name, $group = 'web')
$middlewareGroups = Str::before(Str::after($httpKernel, '$middlewareGroups = ['), '];');
$middlewareGroup = Str::before(Str::after($middlewareGroups, "'$group' => ["), '],');

if (! Str::contains($middlewareGroup, $name)) {
$modifiedMiddlewareGroup = str_replace(
$after.',',
$after.','.PHP_EOL.' '.$name.',',
$middlewareGroup,
);

file_put_contents(app_path('Http/Kernel.php'), str_replace(
$middlewareGroups,
str_replace($middlewareGroup, $modifiedMiddlewareGroup, $middlewareGroups),
$httpKernel
));
if (str_contains($middlewareGroup, $name)) {
return;
}

$modifiedMiddlewareGroup = str_replace(
$after.',',
$after.','.PHP_EOL.' '.$name.',',
$middlewareGroup,
);

file_put_contents(app_path('Http/Kernel.php'), str_replace(
$middlewareGroups,
str_replace($middlewareGroup, $modifiedMiddlewareGroup, $middlewareGroups),
$httpKernel
));
}

private function appendTailwindStylesToLayouts()
Expand All @@ -119,10 +121,10 @@ private function existingLayoutFiles()

private function installMiddleware(string $middleware)
{
if (file_exists(base_path('bootstrap/app.php'))) {
$this->installMiddlewareToBootstrap($middleware);
} else {
if (file_exists(app_path('Http/Kernel.php'))) {
$this->installMiddlewareAfter('SubstituteBindings::class', $middleware);
} else {
$this->installMiddlewareToBootstrap($middleware);
}
}

Expand Down

0 comments on commit 8036369

Please sign in to comment.