Purge Task
Contao has a special maintenance module with which you can execute various “purging” tasks. By default it contains tasks like purging the search index tables, clearing the asset caches, purging the shared HTTP cache etc.
This article documents how to extend this maintenance module with your own purge actions.
Purging tasks are divided into 3 categories:
tables- for purging database tables.folders- for purging the contents of filesystem folders.custom- for anything else (e.g. clearing the HTTP cache, or recreating symlinks).
Registration of purge task are done via the $GLOBALS['TL_PURGE'] table. Each task needs to have a callback that
defines the class and method that runs the purge task. The tables and folders purge tasks also need to define their
affected tables and folders with that registration.
The registered callback can be a service. However, that service needs to be public.
Purging Tables
If you crated your own database tables (via a DCA or Doctrine entities) that need to be able to be purged by back end administrators, you can register a purge task for that in the following way:
The callback key references the class and method to be run while the affected key references the database tables
that will be affected by this purge task. This will also make the purge maintenance module show the current amount of
records within that table.
You will also need translation labels:
This will then show the following for the purge module:
Purging Folders
If your application writes some files into specific directories which back end administrators need to be able to purge, you can register a purge task for that in the following way:
The callback key references the class and method to be run while the affected key references the folders that will
be affected by this purge task. This will also make the purge maintenance module show the current amount of files within
those folders.
You will also need translation labels:
This will then show the following for the purge module:
Custom Action
Other purge tasks that do not fall into the tables or folders category can be put into the custom category, where
you only have to define the callback:
You will also need translation labels:
This will then show the following for the purge module:


