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