Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
other
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
12 Jan 2013 at 13:05 UTC
Updated:
29 Jul 2014 at 21:45 UTC
Jump to comment: Most recent file
As we are taking inspiration from the whole Symfony 'Bag' thing, I tihnk we should add an all() method that returns all instantiated plugin instances. This seems like a good idea and as we want a complete API for this class.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1886894-1.patch | 1.6 KB | damiankloip |
| d8.pluginBag-all.patch | 758 bytes | damiankloip |
Comments
Comment #1
damiankloip commentedAnd a test?
Comment #2
dawehnerI agree that there might be usecases for that and we shouldn't limit it.
We have proper testing as well, so that's RTBC from my site.
Comment #3
catchHmm really? That mostly defeats the point of the class I think given it originally went in so there'd be a proper iterator. If you do all() aren't you going to just foreach() over them again anyway?
At the least this could use a comment to recommend iterating or whatever else on the class itself.
Comment #4
dawehner@damian
What is a use-case for all? If you need all you might shouldn't start using it in the first place.
Comment #5
damiankloip commentedI was just thinking that these 'bags' generally have an all() method, also, this is useful for debugging I think, instead of having to iterate over the pluginBag each time.
I don't feel overly strongly about this, so @catch, I leave this up to you. It just seems that this was originally based/inspired by the symfony parameterBags, so we should try to be consistent with those...
Comment #6
damiankloip commentedSee #1868772: Convert filters to plugins for pretty much a similar usage in the FilterBag class. This does make sense for things like administration pages etc...
Comment #7
dawehnerSo there is a usecase.
To be honest, I still not really sure whether plugin bags are useful for objects, which need all of the plugin instances all the time (beside the object is not used at all), but yeah if drupal does something then like crazy.
Patch does still apply.
Comment #8
damiankloip commentedLooks like #1938654: Export all properties of all views handlers and plugins will probably have a use case for this too, as we will need to iterate over all displays before saving.
Comment #9
webchickCatch didn't seem to like this before, so moving it back to him for final sign-off.
Comment #10
catchWhat's wrong with foreaching over the pluginbag for this?
Comment #11
damiankloip commentedNothing, that will work just fine :)