From 330490afc83b56cc2021f29d5b17d6fe4d8d223c Mon Sep 17 00:00:00 2001 From: Pavel Volokitin Date: Mon, 6 May 2013 11:35:30 +0600 Subject: [PATCH] added kernel.cache_clearer tag to the ref --- reference/dic_tags.rst | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 46bce20daff..68ad4e13834 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -24,6 +24,8 @@ the AsseticBundle has several tags that aren't listed here. +-----------------------------------+---------------------------------------------------------------------------+ | `form.type_guesser`_ | Add your own logic for "form type guessing" | +-----------------------------------+---------------------------------------------------------------------------+ +| `kernel.cache_clearer`_ | Register your service to be called during the cache clearing process | ++-----------------------------------+---------------------------------------------------------------------------+ | `kernel.cache_warmer`_ | Register your service to be called during the cache warming process | +-----------------------------------+---------------------------------------------------------------------------+ | `kernel.event_listener`_ | Listen to different events/hooks in Symfony | @@ -144,6 +146,57 @@ tag its service definition with ``form.type_guesser`` (it has no options). To see an example of how this class might look, see the ``ValidatorTypeGuesser`` class in the ``Form`` component. +kernel.cache_clearer +-------------------- + +**Purpose**: Register your service to be called during the cache clearing process + +Cache clearing occurs whenever you call ``cache:clear`` command. If your +bundle caches files, you should add custom cache clearer for clearing those +files during the cache clearing process. + +In order to register your custom cache clearer, first you must create a +service class:: + + // src/Acme/MainBundle/Cache/MyClearer.php + namespace Acme\MainBundle\Cache; + + use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface; + + class MyClearer implements CacheClearerInterface + { + public function clear($cacheDir) + { + // clear your cache + } + + } + +Then register this class and tag it with ``kernel.cache:clearer``: + +.. configuration-block:: + + .. code-block:: yaml + + services: + my_cache_clearer: + class: Acme\MainBundle\Cache\MyClearer + tags: + - { name: kernel.cache_clearer } + + .. code-block:: xml + + + + + + .. code-block:: php + + $container + ->register('my_cache_clearer', 'Acme\MainBundle\Cache\MyClearer') + ->addTag('kernel.cache_clearer') + ; + kernel.cache_warmer -------------------