php/src/Core/Front/Cli/Boot.php
Snider 208cb93c95
All checks were successful
CI / PHP 8.3 (pull_request) Successful in 2m32s
CI / PHP 8.4 (pull_request) Successful in 2m17s
fix(dx): code style fixes, strict_types, and test repair
- Remove non-existent src/Core/Service/ from CLAUDE.md L1 packages list
- Fix LifecycleEventsTest: remove dependency on McpToolHandler interface
  (lives in core-mcp, not needed since McpToolsRegistering stores class
  name strings)
- Run Laravel Pint to fix PSR-12 violations across all source and test files
- Add missing declare(strict_types=1) to 18 PHP files (tests, seeders,
  Layout.php, GenerateServiceOgImages.php)

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 09:03:50 +00:00

80 lines
2 KiB
PHP

<?php
/*
* Core PHP Framework
*
* Licensed under the European Union Public Licence (EUPL) v1.2.
* See LICENSE file for details.
*/
declare(strict_types=1);
namespace Core\Front\Cli;
use Core\Actions\ScheduleServiceProvider;
use Core\Events\ConsoleBooting;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
/**
* CLI frontage - console/artisan context.
*
* Fires ConsoleBooting event and processes module requests for:
* - Artisan commands
* - Translations
* - Middleware aliases
* - Policies
* - Blade component paths
*/
class Boot extends ServiceProvider
{
public function boot(): void
{
// Only fire for CLI context
if (! $this->app->runningInConsole()) {
return;
}
$this->app->register(ScheduleServiceProvider::class);
$this->fireConsoleBooting();
}
protected function fireConsoleBooting(): void
{
$event = new ConsoleBooting;
event($event);
// Process commands
if (! empty($event->commandRequests())) {
$this->commands($event->commandRequests());
}
// Process translations
foreach ($event->translationRequests() as [$namespace, $path]) {
if (is_dir($path)) {
$this->loadTranslationsFrom($path, $namespace);
}
}
// Process middleware aliases
$router = $this->app->make(Router::class);
foreach ($event->middlewareRequests() as [$alias, $class]) {
$router->aliasMiddleware($alias, $class);
}
// Process policies
foreach ($event->policyRequests() as [$model, $policy]) {
Gate::policy($model, $policy);
}
// Process blade component paths
foreach ($event->bladeComponentRequests() as [$path, $namespace]) {
if (is_dir($path)) {
Blade::anonymousComponentPath($path, $namespace);
}
}
}
}