diff --git a/core/state-processors.md b/core/state-processors.md index abca3da7609..28137a95fd1 100644 --- a/core/state-processors.md +++ b/core/state-processors.md @@ -264,6 +264,41 @@ final class UserProcessor implements ProcessorInterface } ``` +Next, we bind the [PersistProcessor](https://github.com/api-platform/core/blob/main/src/Laravel/Eloquent/State/PersistProcessor.php) and [RemoveProcessor](https://github.com/api-platform/core/blob/main/src/Laravel/Eloquent/State/RemoveProcessor.php) in our Service Provider: + +```php +app->tag(UserProcessor::class, ProcessorInterface::class); + + $this->app->singleton(UserProcessor::class, function (Application $app) { + return new UserProcessor( + $app->make(PersistProcessor::class), + $app->make(RemoveProcessor::class), + ); + }); + } + + // ... +} +``` + Finally, configure that you want to use this processor on the User resource: ```php diff --git a/core/state-providers.md b/core/state-providers.md index 9912913c013..49f6b603d0b 100644 --- a/core/state-providers.md +++ b/core/state-providers.md @@ -345,7 +345,37 @@ final class BookRepresentationProvider implements ProviderInterface } ``` -And configure that you want to use this provider on the Book resource: +And we bind the [ItemProvider](https://github.com/api-platform/core/blob/main/src/Laravel/Eloquent/State/ItemProvider.php) in our Service Provider + +```php +app->singleton(BookRepresentationProvider::class, function (Application $app) { + return new BookRepresentationProvider( + $app->make(ItemProvider::class), + ); + }); + } + + //... +} +``` + +Finally, configure that you want to use this provider on the Book resource: ```php