For issues like #1825896: Add module owner to plugin data on handlers it would be good if we could actually use the module owner for a plugin and store it, so that when the plugin is not there, we can provide better details about the dependencies.
When we were using the @Plugin definition for everything, we added the module owner to the actual annotation, but now we are using individual annotation classes (like PluginID) these have been removed.
I say bring this back, but automate this on AnnotatedClassDiscovery and get the module from the namespace.
Comment | File | Size | Author |
---|---|---|---|
#24 | 2022087-24.patch | 4.44 KB | damiankloip |
#24 | interdiff-2022087-24.txt | 657 bytes | damiankloip |
#21 | 2022087-21.patch | 4.44 KB | damiankloip |
#21 | interdiff-2022087-21.txt | 4.37 KB | damiankloip |
#16 | 2022087-16.patch | 4.39 KB | damiankloip |
Comments
Comment #1
amateescu CreditAttribution: amateescu commentedYes! I think this is immensly useful :)
Comment #3
damiankloip CreditAttribution: damiankloip commentedActually fixing the tests for annotation discovery will also cover what this patch adds.
Comment #4
EclipseGc CreditAttribution: EclipseGc commentedBeen saying we should do this for a while now. Big ++ from me. The only problem is that this should be done to Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery, not the Component class.
Eclipse
Comment #5
damiankloip CreditAttribution: damiankloip commentedOk, that makes sense. We will pretty much have to copy the method over verbatim as I have it in my patch.
Comment #6
damiankloip CreditAttribution: damiankloip commentedHow about this instead? After speaking to Eclipse on IRC, we should preserve the class inheritance a bit better.
interdiff is based on patch from #3
Comment #7
EclipseGc CreditAttribution: EclipseGc commentedif 6 passes, I'm totally RTBC
Eclipse
Comment #8
damiankloip CreditAttribution: damiankloip commentedThere was one stray empty line, thanks amateescu!
Comment #9
damiankloip CreditAttribution: damiankloip commentedOk, also speaking to alexpott on IRC, we should only add the module key if it hasn't already been set.
Comment #10
amateescu CreditAttribution: amateescu commentedYep, I think it's only fair to not override this property if the plugin annotation already provides it.
Comment #11
tim.plunkett+1, nice regex
Comment #12
alexpottCommitted 0360c07 and pushed to 8.x. Thanks!
Comment #13
tstoecklerHmm.. this doesn't make very much sense for plugins provided by Drupal/Core. Couldn't we have gone with something generic like 'owner' or 'provider'?
Comment #14
damiankloip CreditAttribution: damiankloip commentedI think only modules can provide plugins currently (correct me if I'm wrong)? Until that changes I think this is good. If it does, maybe this should be reviewed..
Comment #15
tstoecklerWell if Drupal/Core can't provide plugins then that's certainly a regression: #1828616: AnnotatedClassDiscovery is not finding plugins in Drupal\(Core|Component)\COMPONENT_NAME\Plugin directory :-)
#1821846: Consider better naming conventions for plugin types owned by includes doesn't seem like it's going anywhere lately, but I still think this particular bit is unnecessary.
$plugin['module'] == 'Core' // WTF??
$plugin['owner'] == 'Core'
$plugin['owner'] == 'node' // makes sense, IMO
Comment #16
damiankloip CreditAttribution: damiankloip commentedYes, sorry. There is one implementation of this in Core nowdays - Validation constraints!
So, we should just change to this?
Comment #17
tstoecklerYay, thanks for the quick turnaround. I hadn't found the validation constraint plugins myself, but thanks for digging that up.
Assuming this is green, it's RTBC.
Comment #18
EclipseGc CreditAttribution: EclipseGc commentedSeems somewhat pedantic to me, but I'm also not really opposed so++
We should probably file followups to remove the module annotation from as many plugins as possible now in favor of owner.
Eclipse
Comment #19
msonnabaum CreditAttribution: msonnabaum commentedIs "owner" the right word here? Usually we use that to refer to users. What about "provider" instead?
Comment #20
effulgentsia CreditAttribution: effulgentsia commentedSpecifically, that's the only way the term is used in HEAD. Well, except for in the theme system, where it's used to refer to a file, but that's a separate thing we might want to fix in a different issue.
"owner" does have history as referring to a module name in CTools and I think some D8 CMI issues, but not in any HEAD code. Given that, I agree with #19's suggestion of 'provider'. Or if someone has other naming ideas, lets consider them.
Comment #21
damiankloip CreditAttribution: damiankloip commentedHere is a patch to change it to 'provider' too.
I really don't care either way, and agree with eclipses comment in #18. Someone choose one, and let's just go with it. The expression 'Bigger fish to fry' springs to mind :)
Comment #23
dawehnerI guess this string should also refer to provider.
Comment #24
damiankloip CreditAttribution: damiankloip commentedGood spot. Minimal comment change, leaving as rtbc.
Comment #25
alexpottCommitted e865959 and pushed to 8.x. Thanks!
Comment #26.0
(not verified) CreditAttribution: commentedDoesn't need tests.