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.
We want to leverage annotations to ease providing data types to the typed data API. Right now, plugins are not found below core component directories, so the API uses hook discovery and an ugly system_data_type_info() implementation.
Let's resolve #1828616: AnnotatedClassDiscovery is not finding plugins in Drupal\(Core|Component)\COMPONENT_NAME\Plugin directory, then switch discovery over. Postponed on this issue.
Comment | File | Size | Author |
---|---|---|---|
#41 | interdiff.txt | 705 bytes | fubhy |
#41 | 1867856-41.patch | 77.81 KB | fubhy |
#35 | interdiff.txt | 5.33 KB | fubhy |
#35 | 1867856-33.patch | 78.93 KB | fubhy |
#29 | 1867856-29.patch | 77.84 KB | fubhy |
Comments
Comment #1
fagoGiven that we already can pass custom namespace to the annotation discovery, we do not have to postpone this on the proper solution of #1828616: AnnotatedClassDiscovery is not finding plugins in Drupal\(Core|Component)\COMPONENT_NAME\Plugin directory any more.
Comment #2
fagodiscussed with berdir and we thinkg going with "DataType" as directory name here should be fine.
Comment #3
EclipseGc CreditAttribution: EclipseGc commentedWhat are you going to name your annotation class?
Comment #4
fagoWe'd go with @DataType ?
Comment #5
fubhy CreditAttribution: fubhy commentedComment #6
fubhy CreditAttribution: fubhy commentedComment #7
fubhy CreditAttribution: fubhy commentedNote: I wrote the patch based on #1969728: Implement Field API "field types" as TypedData Plugins as suggested by @fago. Please review
1867856-including-field-type-plugins.patch
Comment #9
fubhy CreditAttribution: fubhy commented#6: 1867856-including-field-type-plugins.patch queued for re-testing.
Comment #11
fubhy CreditAttribution: fubhy commentedComment #13
fubhy CreditAttribution: fubhy commented#1969728: Implement Field API "field types" as TypedData Plugins just got commited. Here is a re-roll including fixes for those test fails.
Comment #14
BerdirSame patch, just with moves, so that the patch is much easier to review.
Comment #15
fubhy CreditAttribution: fubhy commentedWe probably want to put more in there (like constraints, etc.). The rest is mostly moving things around.
Comment #16
dawehnerThe point is to document each property, so please add label and maybe also description.
Comment #17
fubhy CreditAttribution: fubhy commentedThis issue just moves stuff around. That documentation was not introduced here. Lets fix it in a follow-up.
Comment #18
EclipseGc CreditAttribution: EclipseGc commentedOk, I reviewed this and then managed to lose my review so, me--
The short version is this:
The Annotation class is all wrong, none of the stuff in it needs to be there and the stuff that should be there isn't.
The TypedDataManager should extend DefaultPluginManager and leverage the goodness there. The TypedDataManager should also stop proxying its stuff to TypedDataFactory. We should just move the contents of TypedDataFactory into the manager and call it good. Likewise all references to $this->discovery and $this->factory should go once that cleanup is done.
It should all look a little something like this:
Eclipse
Comment #19
fagoAgreed - it should not hold up this patch through as it's nothing that has to go through before code freeze, so I'm not sure we should deal with it here or in a follow-up issue.
Comment #20
fagoops, just realised you re-rolled the patch, so forget my comment about holding anything up.. :D
interdiff looks good except for:
That's not the name, it's description.
Comment #21
EclipseGc CreditAttribution: EclipseGc commentedAfter a little discussion with fago in irc I found that there should be an alter hook for the definitions, so I readded that back in. if 18 comes back green, then we're obviously missing tests. This patch also fixes his description issue from 20
Eclipse
Comment #23
fgmJust wanted to note that, should this issue does not reach resolution, hook_data_type_info() would need to be documented: it current has two implementations, but no definition in a .api.php file.
Comment #24
Berdir@fgm: This patch removes a hook_data_type_info() in system.api.php?
Comment #25
fgm@berdir : yes, I can see that now. Don't know why I could not find it yesternight, must have been too late. Just ignore my remark.
Comment #26
fubhy CreditAttribution: fubhy commentedRefactoring TypedConfigManager to include SchemaDiscovery and that factory and extended PluginManagerBase directly instead.
Comment #27
EclipseGc CreditAttribution: EclipseGc commentedOk, that whole manager is totally weird, but if we have to hack around it for the time being, I'm 100% ++ My contributions to this were specifically around using DefaultPluginManager which is pretty straight forward and well represented elsewhere in core, so I feel pretty comfortable rtbcing this.
Eclipse
Comment #28
fagoThis is incomplete (constraints) - be sure to replicate all the docs from hook_data_type_info().
Else this looks good to me.
Comment #29
fubhy CreditAttribution: fubhy commentedComment #30
Jose Reyero CreditAttribution: Jose Reyero commentedThough I don't really understand the full extent of this patch, the TypedConfigManager changes look ok to me
Comment #31
EclipseGc CreditAttribution: EclipseGc commentedOk then, let's try this again.
Eclipse
Comment #32
fagoYep, this looks good now!
Comment #33
Jose Reyero CreditAttribution: Jose Reyero commentedRelated, as we are moving around SchemaDiscovery, there's some issue with that class: it loads all the data from the constructor instead of from getDefinitions(), and that's the reason why just instantiating it adds some processing and creates lots of plugins...
(That could be another patch I guess, just in case this needs some reroll it could be fixed here too, otherwise I'll create some follow up...)
Comment #34
EclipseGc CreditAttribution: EclipseGc commentedThat entire PluginType (TypedConfigManager) needs some serious review. I think that needs its own issue though.
Eclipse
Comment #35
fubhy CreditAttribution: fubhy commentedFixing some problems with TypedConfigManager. Jose found a performance problem with TypedConfigManager which we can fix right here. The schema should not always be loaded on construct directly but rather only when it's requested in ::getDefinitions(). Also, ::getDefinition() should not alter $this->definitions. In fact, there should probably be another method that covers these fallback scenariors. But that's follow-up material.
Comment #36
fubhy CreditAttribution: fubhy commentedOkay, RTBC for #29 again. Let's fix the performance issues in a follow-up so we can get this in now.
Please commit the patch from comment #29
Comment #37
fubhy CreditAttribution: fubhy commentedOpened a follow-up for the TypedConfigManager and uploaded the patch there: #2030859: Improve TypedConfigManager. Let's get #29 in asap (very helpful for param converter / typed data).
Comment #38
fubhy CreditAttribution: fubhy commented*meow*
Comment #39
kfritscheComment #40
kfritscheComment #41
fubhy CreditAttribution: fubhy commentedI blame the reviewers.
Comment #42
EclipseGc CreditAttribution: EclipseGc commentedAssuming that passes, this is still rtbc. It was just a comment change.
Eclipse
Comment #43
BerdirRaising to major, as discussed with @xjm.
Comment #44
alexpottCommitted 2c2f5f5 and pushed to 8.x. Thanks!
Comment #45
andypostThere's some left - follow-up #1913620: Move comment TypeData to proper place
Comment #46
BerdirUpdated https://drupal.org/node/1806650 and added an example of how to define a data type, did not exist before.