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.
Depends on #1969728: Implement Field API "field types" as TypedData Plugins
Instructions are on #2014671: [META] Convert all field types to plugins
Comment | File | Size | Author |
---|---|---|---|
#15 | 2015693-convert-typed-data-link-module-15.patch | 7.49 KB | yched |
#15 | interdiff.txt | 590 bytes | yched |
#12 | 2015693-convert-typed-data-link-module-12.patch | 7.51 KB | mordonez |
#12 | interdiff.txt | 691 bytes | mordonez |
#10 | 2015693-convert-typed-data-link-module-10.patch | 7.5 KB | mordonez |
Comments
Comment #1
swentel CreditAttribution: swentel commentedcommit at http://drupalcode.org/sandbox/yched/1736366.git/commitdiff/9931286d599e8...
Comment #2
swentel CreditAttribution: swentel commentedComment #3
aspilicious CreditAttribution: aspilicious commentedI see this in the sandbox commit, this ok?
Comment #4
swentel CreditAttribution: swentel commentedNah, was wrong, have that ok locally already
Comment #5
mordonez CreditAttribution: mordonez commentedHi,
I updated the patch with the same format as Telephone field (namespace corrections and annotations).
Comment #6
mordonez CreditAttribution: mordonez commentedSorry I missed to add new and deleted files
Comment #7
mordonez CreditAttribution: mordonez commentedSorry I missed to add the new and deleted files
Comment #8
aspilicious CreditAttribution: aspilicious commentedComment #9
yched CreditAttribution: yched commentedThanks @mordonez !
the instance should be accessed through $this->getInstance().
No need for the isset() check, it should always be set (I know this comes from the existing code, but let's clean this while we're here)
Let's avoid going through getValue().
This can be:
$this->url = trim($this->url);
$this->title = trim($this->title);
Comment #10
mordonez CreditAttribution: mordonez commentedThanks @yched.
here the corrections.
Comment #11
yched CreditAttribution: yched commentedthanks @mordonez!
hint: it's a good practice, when you post a new version of a patch, to also post an "interdiff" - a .txt file showing the diff between the previous and the new version. It helps reviews tremendously :-)
See https://drupal.org/documentation/git/interdiff (if you're on linux, the interdiff command line provided by the patchutils package is really handy).
Last nitpick - my bad, I should have spotted that earlier:
The goal is to make our FieldItem classes (like LinkItem here) be usable for configurable fields (that can be added through the UI) as well as base entity fields (that are hardcoded in the Entity definition).
This means relying as little as possible on the Field / FieldInstance definition structures that are specific to configurable fields, and instead use the FieldDefinitionInterface.
In this case, this will be as simple as replacing this line:
'#default_value' => $this->getInstance()->settings['title'],
by
'#default_value' => $this->getFieldDefinition()->getFieldSetting('title'),
:-)
Comment #12
mordonez CreditAttribution: mordonez commentedthanks for the interdiff's advice
here the patch that uses the FieldDefinitionInterface
Comment #13
mordonez CreditAttribution: mordonez commentedComment #14
yched CreditAttribution: yched commentedThanks !
Comment #15
yched CreditAttribution: yched commentedJust removed the 'module' entry now that #2041423: Rely on 'provider' instead of 'module' for Field plugin types is in.
Comment #16
alexpottCommitted a7dbbd5 and pushed to 8.x. Thanks!