Skip to content

Commit e86e80d

Browse files
authored
Improve docs (#124)
1 parent d65edca commit e86e80d

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ class Post
362362

363363
### Adding Conditional Logic with Expression Language
364364

365-
[Symfony's Expression Language component](https://symfony.com/doc/current/components/expression_language.html) can be
365+
[Symfony's ExpressionLanguage component](https://symfony.com/doc/current/components/expression_language.html) can be
366366
used to add conditions that must be met for the purge to occur. In these expressions, the entity is available as the
367367
`obj` variable:
368368

docs/complex-route-params.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ values to create flexible and powerful purge rules.
77
## Using Nested Properties
88

99
You can access nested properties of an entity to define route parameters by
10-
using [Symfony's Property Access](https://symfony.com/doc/current/components/property_access.html) syntax:
10+
using [Symfony's PropertyAccess](https://symfony.com/doc/current/components/property_access.html) syntax:
1111

1212
```php
1313
#[Route('/author/{id<\d+>}', name: 'author_details', methods: 'GET')]
@@ -134,7 +134,25 @@ public function listAction(string $lang)
134134
}
135135
```
136136

137-
To make this work, ensure your service is tagged correctly in the service configuration:
137+
By default, the entire entity being purged is passed to the route parameter service.
138+
If your service only needs a specific part of the entity, you can limit what is passed by providing a second argument to
139+
`DynamicValues`.
140+
141+
This argument is a **Symfony PropertyAccess property path** and will be resolved against the entity before being passed
142+
to the service:
143+
144+
```php
145+
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\DynamicValues;
146+
147+
#[Route('/posts/{type}', name: 'posts_list', methods: 'GET')]
148+
#[PurgeOn(Post::class, routeParams: ['type' => new DynamicValues('my_service', 'property')])]
149+
public function listAction(string $lang)
150+
{
151+
}
152+
```
153+
154+
To make the service available for resolving route parameter values, ensure it is tagged correctly in the service
155+
configuration:
138156

139157
```yaml
140158
# services.yaml

docs/purge-subscriptions-using-yaml.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@ posts_list:
6363
class: App\Entity\Post
6464
route_params:
6565
type: !dynamic my_service
66+
67+
# Limiting the value passed to the service using a property path
68+
posts_list:
69+
class: App\Entity\Post
70+
route_params:
71+
type: !dynamic [ my_service, prop ]
6672
```

tests/Functional/TestApplication/Controller/VehicleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class VehicleController
1818
#[Route('/{id}/number-of-engines', 'number_of_engines')]
1919
#[AnnotationRoute('/{id}/number-of-engines', name: 'number_of_engines')]
2020
#[PurgeOn(Vehicle::class, target: 'numberOfEngines')]
21-
public function numberOfEnginesAction(Vehicle $animal)
21+
public function numberOfEnginesAction(Vehicle $vehicle)
2222
{
2323
}
2424
}

0 commit comments

Comments
 (0)