Skip to content

Commit 4536a60

Browse files
mnoconadriendupuis
andauthored
Explicitly listed types supported by Response Tagger (#3109)
* Expliciltly listed types supported by Response Tagger * PHP & JS CS Fixes * Rebuild * Added highlight * Reduced sample * Added leading slashes * Apply suggestion from @mnocon * Apply suggestions from code review Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> --------- Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
1 parent dafaa48 commit 4536a60

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php declare(strict_types=1);
2+
3+
/** @var \Ibexa\Contracts\HttpCache\ResponseTagger\ResponseTagger $responseTagger */
4+
/** @var \Ibexa\Core\MVC\Symfony\View\ContentValueView|\Ibexa\Core\MVC\Symfony\View\LocationValueView $view */
5+
$responseTagger->tag($view); // When working with a view
6+
7+
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */
8+
$responseTagger->tag($content->getContentInfo()); // When working with a content item
9+
10+
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */
11+
$responseTagger->tag($location); // When working with a location

docs/infrastructure_and_maintenance/cache/http_cache/content_aware_cache.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ The `ConfigurableResponseCacheConfigurator` (`Ibexa\HttpCache\ResponseConfigurat
140140
For example, a `ContentView` is covered both by the `ContentValueViewTagger` and `LocationValueViewTagger`, where the first extracts the content from the `ContentView` and passes it to the `ContentInfoTagger`.
141141
- Value taggers - extract the `Location` and pass it on to the `LocationViewTagger`.
142142

143+
The built-in taggers support the following value types:
144+
145+
- [`ContentInfo`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html)
146+
- [`Location`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Location.html)
147+
- Any view implementing `Ibexa\Core\MVC\Symfony\View\ContentValueView`
148+
- Any view implementing `Ibexa\Core\MVC\Symfony\View\LocationValueView`
149+
150+
!!! warning
151+
152+
If a value of any other type is passed (for example, a [`Content`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) object), no tagger matches and the call has no effect.
153+
143154
## DispatcherTagger
144155

145156
Accepts any value and passes it on to every tagger registered with the service tag `ibexa.cache.http.response.tagger`.
@@ -150,17 +161,10 @@ For tagging needs in controllers, there are several options, here presented in r
150161

151162
1\. Reusing `DispatcherTagger` to pick correct tags.
152163

153-
Examples for tagging everything needed for content using the autowireable `ResponseTagger` interface:
154-
155-
``` php
156-
/** @var \Ibexa\Contracts\HttpCache\ResponseTagger\ResponseTagger $responseTagger */
157-
158-
// If you have a View object you can simply call:
159-
$responseTagger->tag($view);
164+
Examples for tagging everything needed for content using the autowireable [`ResponseTagger`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-HttpCache-ResponseTagger-ResponseTagger.html) interface:
160165

161-
// Or if you have content / Location object only, you can instead provide content info and Location:
162-
$responseTagger->tag($contentInfo);
163-
$responseTagger->tag($location);
166+
``` php hl_lines="3 6 9"
167+
[[= include_code('code_samples/cache/http_cache/src/response_tagging.php', 3, 11) =]]
164168
```
165169

166170
2\. Use `ContentTagInterface` API for content related tags.

0 commit comments

Comments
 (0)