From 6c75707cea24446f6ad4ec0e388bd1d762af1aa7 Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Tue, 5 Aug 2025 13:12:50 +0200 Subject: [PATCH 1/2] [Docs] Add "Configure the routes' name" section to resource/configure_your_operations.md --- docs/resource/configure_your_operations.md | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/docs/resource/configure_your_operations.md b/docs/resource/configure_your_operations.md index 0ba40cc3..eaf84038 100644 --- a/docs/resource/configure_your_operations.md +++ b/docs/resource/configure_your_operations.md @@ -447,7 +447,7 @@ use Sylius\Resource\Metadata\Update; #[AsResource( routePrefix: 'admin', operations: [ - new Index(), + new Index(routePrefix: ''), new Create(), new Update(), new Delete(), @@ -463,13 +463,55 @@ class Book implements ResourceInterface | Name | Method | Path | |----------------------|-----------------|--------------------------| -| app_book_index | GET | /admin/books/ | +| app_book_index | GET | /books/ | | app_book_create | GET, POST | /admin/books/new | | app_book_update | GET, PUT, PATCH | /admin/books/{id}/edit | | app_book_delete | DELETE | /admin/books/{id} | | app_book_bulk_delete | DELETE | /admin/books/bulk_delete | | app_book_show | GET | /admin/books/{id} | +### Configure the routes' name + +It customizes the route name for individual operations. + +{% code title="src/Entity/Book.php" lineNumbers="true" %} +```php +namespace App\Entity; + +use Sylius\Resource\Model\ResourceInterface; +use Sylius\Resource\Metadata\AsResource; +use Sylius\Resource\Metadata\BulkDelete; +use Sylius\Resource\Metadata\Create; +use Sylius\Resource\Metadata\Delete; +use Sylius\Resource\Metadata\Index; +use Sylius\Resource\Metadata\Show; +use Sylius\Resource\Metadata\Update; + +#[AsResource( + operations: [ + new Index(routeName: 'library_book_list'), + new Create(routeName: 'library_book_add'), + new Update(), + new Delete(), + new BulkDelete(), + new Show(), + ], +) +class Book implements ResourceInterface +{ +} +``` +{% endcode %} + +| Name | Method | Path | +|----------------------|-----------------|--------------------------| +| library_book_list | GET | /books/ | +| library_book_add | GET, POST | /books/new | +| app_book_update | GET, PUT, PATCH | /books/{id}/edit | +| app_book_delete | DELETE | /books/{id} | +| app_book_bulk_delete | DELETE | /books/bulk_delete | +| app_book_show | GET | /books/{id} | + ### Configure the section It changes the route name for each operation. From 0fa8ab6e15a2d4d865dd207ebdea5007e52925a7 Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Mon, 18 Aug 2025 11:38:35 +0200 Subject: [PATCH 2/2] [Docs] Add clear explanation in code example for custom routePrefix in operations Co-authored-by: Estelle Gaits <74190794+stlgaits@users.noreply.github.com> --- docs/resource/configure_your_operations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resource/configure_your_operations.md b/docs/resource/configure_your_operations.md index eaf84038..24ece1b0 100644 --- a/docs/resource/configure_your_operations.md +++ b/docs/resource/configure_your_operations.md @@ -447,7 +447,7 @@ use Sylius\Resource\Metadata\Update; #[AsResource( routePrefix: 'admin', operations: [ - new Index(routePrefix: ''), + new Index(routePrefix: ''), // you can also customize the route prefix at the operation level too for extra flexibility new Create(), new Update(), new Delete(),