Skip to content

Commit

Permalink
[New docs] Configure the resource plural name
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 authored and Zales0123 committed Jun 21, 2023
1 parent e885d5e commit 0dbec8d
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion docs/configure_your_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Read the previous chapter to [create a new resource](create_new_resource.md).
* [Implements the Resource interface](#implements-the-resource-interface)
* [Use the Resource attribute](#use-the-resource-attribute)
* [Advanced configuration](#advanced-configuration)
* [Configure the resource name](#configure-the-resource-name)
* [Configure the resource name](#configure-the-resource-name)
* [Configure the resource plural name](#configure-the-resource-plural-name)
<!-- TOC -->

## Implements the Resource interface
Expand Down Expand Up @@ -93,3 +94,31 @@ As an example, on a `show` operation following Twig variables will be available:
| cart | App\Entity\Order |
| operation | Sylius\Component\Resource\Metadata\Show |
| app | Symfony\Bridge\Twig\AppVariable |

### Configure the resource plural name

It defines the resource plural name.

```php
namespace App\Entity;

use Sylius\Component\Resource\Metadata\Resource;
use Sylius\Component\Resource\Model\ResourceInterface;

#[Resource(pluralName: 'library')]
class Book implements ResourceInterface
{
}

```

On your Twig templates, the `books` variable will be replaced by the `library` one.

As an example, on a `index` operation these Twig variables wille be available:

| Name | Type |
|-----------|------------------------------------------|
| resource | App\Entity\Book |
| library | App\Entity\Book |
| operation | Sylius\Component\Resource\Metadata\Index |
| app | Symfony\Bridge\Twig\AppVariable |

0 comments on commit 0dbec8d

Please sign in to comment.