Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#12 | asset_collection_optimizer_listing_deleting-2307419-12.patch | 17.69 KB | Wim Leers |
Comments
Comment #1
Wim LeersComment #3
Wim LeersComment #4
moshe weitzman CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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.