@@ -52,29 +52,26 @@ invalidation requests are flushed to the caching proxy
5252Tagging and Invalidating from PHP Code
5353~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5454
55- To add tags to responses, inject the ``ResponseTagger `` (service
56- ``fos_http_cache.http.symfony_response_tagger ``) and use ``addTags($tags) `` to
57- add tags that will be set on the response::
55+ To add tags to responses, use the ``ResponseTagger::addTags `` method::
5856
5957 use FOS\HttpCacheBundle\Http\SymfonyResponseTagger;
6058
6159 class NewsController
6260 {
63- /**
64- * @var SymfonyResponseTagger
65- */
66- private $responseTagger;
67-
68- public function articleAction($id)
61+ public function articleAction(string $id, SymfonyResponseTagger $responseTagger)
6962 {
70- $this-> responseTagger->addTags(array('news', 'news-' . $id));
63+ $responseTagger->addTags(array('news', 'news-' . $id));
7164
7265 // ...
7366 }
7467 }
7568
76- To invalidate tags, inject the ``CacheManager `` (service ``fos_http_cache.cache_manager ``)
77- and call ``invalidateTags($tags) `` on it::
69+ .. versionadded :: 2.3.2
70+ Autowiring support has been added in version 2.3.2. In older versions of
71+ the bundle, you need to inject the service
72+ ``fos_http_cache.http.symfony_response_tagger `` into your controller.
73+
74+ To invalidate tags, use the ``CacheManager::invalidateTags($tags) `` method::
7875
7976 use FOS\HttpCacheBundle\CacheManager;
8077
@@ -85,16 +82,21 @@ and call ``invalidateTags($tags)`` on it::
8582 */
8683 private $cacheManager;
8784
88- public function editAction($id)
85+ public function editAction(string $id, CacheManager $cacheManager )
8986 {
9087 // ...
9188
92- $this-> cacheManager->invalidateTags(array('news-' . $id));
89+ $cacheManager->invalidateTags(array('news-' . $id));
9390
9491 // ...
9592 }
9693 }
9794
95+ .. versionadded :: 2.3.2
96+ Autowiring support has been added in version 2.3.2. In older versions of
97+ the bundle, you need to inject the service ``fos_http_cache.cache_manager ``
98+ in your controller.
99+
98100Tagging from Twig Templates
99101~~~~~~~~~~~~~~~~~~~~~~~~~~~
100102
0 commit comments