Problem/Motivation
Currently, container rebuild and flushing all caches is done with procedural functions
drupal_rebuild(), drupal_flush_all_caches(), _drupal_flush_css_js().
In #3014752: Convert drupal_flush_all_caches() function to a Cache Clearer service it is being proposed to convert these to a cache rebuilder class.
However, this still leaves a hard-coded piece of code to do all the tasks needed on container rebuild.
As an alternative, I propose to introduce events to decentralize these tasks.
(in fact this is not mutually exclusive with the cache rebuilder class)
Steps to reproduce
Proposed resolution
Introduce one event for "container rebuilt".
Introduce another event for "all caches should be cleared".
Add a subscriber for "container rebuilt" that triggers the "all caches should be cleared" event.
Let different services subscribe to these events.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3375976
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
donquixote commentedActually the hard-coded version as in drupal_flush_all_caches() has one advantage:
The order is fully predictable, without using weights.
Let's go ahead splitting it up, and see later how we like it.