@@ -41,6 +41,8 @@ may also be tags in other bundles you use that aren't listed here.
41
41
+-----------------------------------+---------------------------------------------------------------------------+
42
42
| `form.type_guesser `_ | Add your own logic for "form type guessing" |
43
43
+-----------------------------------+---------------------------------------------------------------------------+
44
+ | `kernel.cache_clearer `_ | Register your service to be called during the cache clearing process |
45
+ +-----------------------------------+---------------------------------------------------------------------------+
44
46
| `kernel.cache_warmer `_ | Register your service to be called during the cache warming process |
45
47
+-----------------------------------+---------------------------------------------------------------------------+
46
48
| `kernel.event_listener `_ | Listen to different events/hooks in Symfony |
@@ -334,6 +336,57 @@ tag its service definition with ``form.type_guesser`` (it has no options).
334
336
To see an example of how this class might look, see the ``ValidatorTypeGuesser``
335
337
class in the ``Form`` component.
336
338
339
+ kernel.cache_clearer
340
+ --------------------
341
+
342
+ **Purpose**: Register your service to be called during the cache clearing process
343
+
344
+ Cache clearing occurs whenever you call ``cache:clear`` command. If your
345
+ bundle caches files, you should add custom cache clearer for clearing those
346
+ files during the cache clearing process.
347
+
348
+ In order to register your custom cache clearer, first you must create a
349
+ service class::
350
+
351
+ // src/Acme/MainBundle/Cache/MyClearer.php
352
+ namespace Acme\MainBundle\Cache;
353
+
354
+ use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
355
+
356
+ class MyClearer implements CacheClearerInterface
357
+ {
358
+ public function clear($cacheDir)
359
+ {
360
+ // clear your cache
361
+ }
362
+
363
+ }
364
+
365
+ Then register this class and tag it with ``kernel.cache:clearer``:
366
+
367
+ .. configuration-block::
368
+
369
+ .. code-block:: yaml
370
+
371
+ services:
372
+ my_cache_clearer:
373
+ class: Acme\MainBundle\Cache\MyClearer
374
+ tags:
375
+ - { name: kernel.cache_clearer }
376
+
377
+ .. code-block:: xml
378
+
379
+ <service id=" my_cache_clearer" class=" Acme\MainBundle\Cache\MyClearer" >
380
+ <tag name=" kernel.cache_clearer" />
381
+ </service>
382
+
383
+ .. code-block:: php
384
+
385
+ $container
386
+ ->register('my_cache_clearer', 'Acme\MainBundle\Cache\MyClearer')
387
+ ->addTag('kernel.cache_clearer')
388
+ ;
389
+
337
390
kernel.cache_warmer
338
391
-------------------
339
392
0 commit comments