Problem/Motivation
In D8 HEAD, it's impossible to list or delete all aggregate assets using an API. One must manipulate private data: State entries. But contrib-provided overrides of the default asset.(css|js).collection_optimizer services may choose not to use State at all, so this is a gap in the asset API.
It's also a blocker for #2258313: Add license information to aggregated assets (specifically see #17 there).
Proposed resolution
Add this to AssetCollectionOptimizerInterface:
/**
* Returns all optimized asset collections assets.
*
* @return string[]
* URIs for all optimized asset collection assets.
*/
public function getAll();
/**
* Deletes all optimized asset collections assets.
*/
public function deleteAll();
Remaining tasks
Review.
User interface changes
None.
API changes
- API addition:
AssetCollectionOptimizerInterface::getAll()
- API addition:
AssetCollectionOptimizerInterface::deleteAll()
- API removal:
drupal_clear_css_cache(), drupal_clear_js_cache() — this should use \Drupal::service('asset.(css|js).collection_optimizer')->deleteAll() instead now.
Comments
Comment #1
wim leersComment #3
wim leersComment #4
moshe weitzman commentedThis code moved from drupal_clear_js_cache() to locale module. Is it really only needed when locale is enabled?
Comment #6
wim leers#4: yes, it is.
Comment #7
wim leersShould be green now.
Comment #9
wim leersStupid me. This will be green.
Comment #10
moshe weitzman commentedOK, RTBC then. I reviewed this earlier.
Comment #11
alexpottThese are all API changes - I'd prefer to deprecate. See:
Comment #12
wim leersDone.
Change record created: https://www.drupal.org/node/2317841.
Comment #13
alexpottCommitted d7d5872 and pushed to 8.0.x. Thanks!
Comment #16
yesct commentedchanging to use the more common tag, so the less common one can be deleted, so it does not show up in the auto complete and confuse people.