Skip to content

Commit 2551cd3

Browse files
committed
Expliciltly listed types supported by Response Tagger
1 parent bffcce1 commit 2551cd3

2 files changed

Lines changed: 24 additions & 9 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: 13 additions & 9 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 recognize 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+
!!! warn
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:
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:
154165

155166
``` 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);
160-
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);
167+
[[= include_file('code_samples/cache/http_cache/src/response_tagging.php') =]]
164168
```
165169

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

0 commit comments

Comments
 (0)