29 lines
801 B
PHP
29 lines
801 B
PHP
<?php
|
|
|
|
namespace Engelsystem\Http\Validation;
|
|
|
|
use Engelsystem\Application;
|
|
use Engelsystem\Container\ServiceProvider;
|
|
use Engelsystem\Controllers\BaseController;
|
|
|
|
class ValidationServiceProvider extends ServiceProvider
|
|
{
|
|
public function register()
|
|
{
|
|
$validates = $this->app->make(Validates::class);
|
|
$this->app->instance(Validates::class, $validates);
|
|
|
|
$validator = $this->app->make(Validator::class);
|
|
$this->app->instance(Validator::class, $validator);
|
|
$this->app->instance('validator', $validator);
|
|
|
|
$this->app->afterResolving(function ($object, Application $app) {
|
|
if (!$object instanceof BaseController) {
|
|
return;
|
|
}
|
|
|
|
$object->setValidator($app->get(Validator::class));
|
|
});
|
|
}
|
|
}
|