Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions docs/resource/configure_your_operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ use Sylius\Resource\Metadata\Update;
#[AsResource(
routePrefix: 'admin',
operations: [
new Index(),
new Index(routePrefix: ''), // you can also customize the route prefix at the operation level too for extra flexibility
new Create(),
new Update(),
new Delete(),
Expand All @@ -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.
Expand Down