Some checks failed
continuous-integration/drone/push Build is failing
- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Data\Validation\NetteValidator;
|
|
use App\Data\Validation\ValidatesArray;
|
|
use App\Services\CorsService;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Nette\Schema\Expect;
|
|
use Nette\Schema\Schema;
|
|
|
|
class CorsServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->app->when(CorsService::class)
|
|
->needs(ValidatesArray::class)
|
|
->give(fn () => static::determineConfigValidator());
|
|
}
|
|
|
|
private static function determineConfigValidator(): ValidatesArray
|
|
{
|
|
return new NetteValidator(
|
|
new \Nette\Schema\Processor(),
|
|
static::getConfigValidationSchema(),
|
|
);
|
|
}
|
|
|
|
private static function getConfigValidationSchema(): Schema
|
|
{
|
|
return Expect::structure([
|
|
'path' => Expect::string(),
|
|
'origin' => Expect::string()->nullable(),
|
|
'methods' => Expect::arrayOf(Expect::string()),
|
|
'headers' => Expect::arrayOf(Expect::string()),
|
|
]);
|
|
}
|
|
}
|