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
I would like to merge in core examples of Typed Data from Typed Example. Maybe as typeddata_example instead of typed_example?
Proposed resolution
Pull out core stuff into its own module and place into examples
Remaining tasks
See #2209627: [meta] Module Checklist for Examples for a full list:
- Inline code comments to describe data definition and data type
- Doc block and group comments to describe high-level about classes
- Add a description page. Describe what type of example this is (it's a back end code example without any UI).
- Needs an actual readme
- Language needs to change to be more beginner-friendly
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#19 | interdiff-18-19.txt | 3.72 KB | jungle |
#19 | 2808785-19.patch | 21.92 KB | jungle |
#4 | interdiff-2808785-2-4.txt | 2.56 KB | mradcliffe |
#4 | examples-2808785-add-typed-data-example-4.patch | 16.57 KB | mradcliffe |
#2 | examples-2808785-add-typed-data-example-2.patch | 16.4 KB | mradcliffe |
Comments
Comment #2
mradcliffeComment #4
mradcliffeThink this will do it.
Comment #6
mradcliffeI guess not. I wonder why it's not finding the classes.
Comment #7
blakehall CreditAttribution: blakehall at Drupalize.Me for Drupalize.Me commentedThis example looks good to me, and once in should allow for some refactoring of the field_example RGB field to use this new Typed Data. I'm assuming that refactoring is beyond the scope of this issue but I'm marking it as Reviewed & Tested since it looks like a solid example to me.
If there is anything I can do to help move the consideration of this patch along please let me know.
Comment #8
Mile23Would be nice to get the tests passing...
At a glance I noticed there's no functional tests of paths created for the example, because there aren't any paths. So we need a description page you can read when it's installed.
Other things to add at the checklist here: #2209627: [meta] Module Checklist for Examples
Also needs a ton of inline comments. For instance, this docblock should explain what all the annotation is doing:
Comment #9
mradcliffeAgreed.
I'm not sure how I missed this those many months ago, but it was glaringly obvious to me this afternoon.
Hopefully this patch addresses the unit test failures and some code standard fixes. This should flip back to Needs Work if it passes.
Comment #10
mradcliffeYep, that was it. Back to Needs work.
Comment #11
mradcliffeI added a description page for the module with some content.
Still needed to be done:
Comment #12
Mile23Patch still applies.. Running the testbot.
Comment #13
jungleThe default branch is 3.x-dev which is Drupal 9 compatible. And I would port this to Drupal 9. :)
Comment #14
jungleRerolled the patch for 3.x, changes explaining in next comment.
Comment #15
jungleTesting on HEAD is broken. Fixing in #3160118: Fix broken testing on HEAD
Comment #16
jungle>Rerolled the patch for 3.x, changes explaining in next comment.
Interrupted in the middle. Forgot...
modules
one line change made for D9
TRUE
should be'TRUE'
Comment #17
jungleFix failed tests in #14 and a little improvements below-relevant.
Should start with "Tests"
Comment #18
jungleForgot to upload the patch...
Comment #19
jungleA few improvements
Comment #20
jungleTagging
Needs issue summary update
for what left to do here or leaving all the rest to separate issues.Comment #21
valthebald@jungle thanks for pushing this example forward!
I'm still looking at the code (it's a big patch, sorry!) Meanwhile, I suggest to use more specific file name for the template - `description.html.twig` would be hard to find in a real theme. Something like `typed-data-description.html.twig` maybe?
Comment #22
valthebaldOther comments:
- it's not clear how to use procedural code from typed_data_example.module. Should this code be moved to a service?
- return values of procedural functions are not used
- description.html.twig is not used anywhere (or I missed it?)
- changes suggested in #19 (defining void return type) are relevant only with PHP7.4, and should be fixed in core classes too, without it static analysis will continue to fail