Files
laravel_school_api_old/app/Providers/SchoolContextServiceProvider.php
T
2026-05-29 04:33:03 -04:00

37 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Providers;
use App\Domain\SchoolCore\Context\SchoolContextFactory;
use App\Domain\SchoolCore\Context\SchoolContextResolver;
use App\Domain\SchoolCore\Context\SchoolContextStore;
use App\Domain\SchoolCore\Context\SchoolContextValidator;
use App\Http\Middleware\ResolveSchoolContext;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Support\ServiceProvider;
final class SchoolContextServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/../../config/school_context.php', 'school_context');
$this->app->singleton(SchoolContextStore::class);
$this->app->bind(SchoolContextFactory::class);
$this->app->bind(SchoolContextResolver::class);
$this->app->bind(SchoolContextValidator::class);
}
public function boot(Kernel $kernel): void
{
$this->publishes([
__DIR__ . '/../../config/school_context.php' => config_path('school_context.php'),
], 'school-context-config');
// Laravel 10/older: also register alias in app/Http/Kernel.php if preferred.
app('router')->aliasMiddleware('school.context', ResolveSchoolContext::class);
}
}