2019-07-09 21:43:18 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-07-09 21:43:18 +02:00
|
|
|
namespace Engelsystem\Http\Validation;
|
|
|
|
|
|
|
|
use Engelsystem\Application;
|
|
|
|
use Engelsystem\Container\ServiceProvider;
|
|
|
|
use Engelsystem\Controllers\BaseController;
|
|
|
|
|
|
|
|
class ValidationServiceProvider extends ServiceProvider
|
|
|
|
{
|
2022-12-14 19:15:20 +01:00
|
|
|
public function register(): void
|
2019-07-09 21:43:18 +02:00
|
|
|
{
|
|
|
|
$validator = $this->app->make(Validator::class);
|
|
|
|
$this->app->instance(Validator::class, $validator);
|
|
|
|
$this->app->instance('validator', $validator);
|
|
|
|
|
2022-12-14 19:15:20 +01:00
|
|
|
$this->app->afterResolving(function ($object, Application $app): void {
|
2019-07-09 21:43:18 +02:00
|
|
|
if (!$object instanceof BaseController) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$object->setValidator($app->get(Validator::class));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|