@@ -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 |
@@ -342,6 +344,57 @@ tag its service definition with ``form.type_guesser`` (it has no options).
342
344
To see an example of how this class might look, see the ``ValidatorTypeGuesser``
343
345
class in the ``Form`` component.
344
346
347
+ kernel.cache_clearer
348
+ --------------------
349
+
350
+ **Purpose**: Register your service to be called during the cache clearing process
351
+
352
+ Cache clearing occurs whenever you call ``cache:clear`` command. If your
353
+ bundle caches files, you should add custom cache clearer for clearing those
354
+ files during the cache clearing process.
355
+
356
+ In order to register your custom cache clearer, first you must create a
357
+ service class::
358
+
359
+ // src/Acme/MainBundle/Cache/MyClearer.php
360
+ namespace Acme\MainBundle\Cache;
361
+
362
+ use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
363
+
364
+ class MyClearer implements CacheClearerInterface
365
+ {
366
+ public function clear($cacheDir)
367
+ {
368
+ // clear your cache
369
+ }
370
+
371
+ }
372
+
373
+ Then register this class and tag it with ``kernel.cache:clearer``:
374
+
375
+ .. configuration-block::
376
+
377
+ .. code-block:: yaml
378
+
379
+ services:
380
+ my_cache_clearer:
381
+ class: Acme\MainBundle\Cache\MyClearer
382
+ tags:
383
+ - { name: kernel.cache_clearer }
384
+
385
+ .. code-block:: xml
386
+
387
+ <service id=" my_cache_clearer" class=" Acme\MainBundle\Cache\MyClearer" >
388
+ <tag name=" kernel.cache_clearer" />
389
+ </service>
390
+
391
+ .. code-block:: php
392
+
393
+ $container
394
+ ->register('my_cache_clearer', 'Acme\MainBundle\Cache\MyClearer')
395
+ ->addTag('kernel.cache_clearer')
396
+ ;
397
+
345
398
kernel.cache_warmer
346
399
-------------------
347
400
0 commit comments