mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 15:43:51 +00:00
Add explicit controller definition requirement for APIs
Updated API creation to require an explicit controller definition. This change has been reflected in the ChillMainExtension and ChillPersonExtension files. Also, it has introduced a new exception, the InvalidCrudConfiguration, which will be thrown when a new API or CRUD is created without this explicit controller definition.
This commit is contained in:
68
MIGRATION.md
68
MIGRATION.md
@@ -46,4 +46,72 @@
|
||||
]);
|
||||
```
|
||||
|
||||
- to keep cleaner definition in container's dependency injection and framework bundle, the definition of crud or api
|
||||
requires to define explicitly a controller.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'apis' => [
|
||||
[
|
||||
'class' => ThirdParty::class,
|
||||
'name' => 'thirdparty',
|
||||
'base_path' => '/api/1.0/thirdparty/thirdparty',
|
||||
'actions' => [
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
Request::METHOD_POST => true,
|
||||
Request::METHOD_PUT => true,
|
||||
Request::METHOD_PATCH => true,
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_GET => ThirdPartyVoter::SHOW,
|
||||
Request::METHOD_HEAD => ThirdPartyVoter::SHOW,
|
||||
Request::METHOD_POST => ThirdPartyVoter::CREATE,
|
||||
Request::METHOD_PUT => ThirdPartyVoter::CREATE,
|
||||
Request::METHOD_PATCH => ThirdPartyVoter::CREATE,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'apis' => [
|
||||
[
|
||||
'class' => ThirdParty::class,
|
||||
'controller' => ThirdPartyApiController::class,
|
||||
'name' => 'thirdparty',
|
||||
'base_path' => '/api/1.0/thirdparty/thirdparty',
|
||||
'actions' => [
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
Request::METHOD_POST => true,
|
||||
Request::METHOD_PUT => true,
|
||||
Request::METHOD_PATCH => true,
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_GET => ThirdPartyVoter::SHOW,
|
||||
Request::METHOD_HEAD => ThirdPartyVoter::SHOW,
|
||||
Request::METHOD_POST => ThirdPartyVoter::CREATE,
|
||||
Request::METHOD_PUT => ThirdPartyVoter::CREATE,
|
||||
Request::METHOD_PATCH => ThirdPartyVoter::CREATE,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user