Implement property classes for all field types and add tests for them.
#1839064: Implement the new entity field API for the list field type
#1839066: Implement the new entity field API for the image field type
#1839068: Implement the new entity field API for the file field type
#1839070: Implement the new entity field API for the taxonomy reference field type
#1839076: Implement the new entity field API for the number field type
#1839078: Implement the new entity field API for the email field type
#1839080: Implement the new entity field API for the link field type
#1839082: Implement the new entity field API for the field test field type
#1847588: Implement the new entity field API for the Entity-Reference field type
#1899378: Implement the new entity field API for the telephone field type
Comments
Comment #1
fagoMoving to the core queue.
Comment #1.0
chx CreditAttribution: chx commentedUpdated issue summary.
Comment #2
yched CreditAttribution: yched commentedA couple hints on what exactly needs to be done would probably help ;-)
Comment #3
amitaibuLittle help for others:
entity_test
extendsEntityNG
-- so all you testing should be against that entity type.Comment #4
amitaibu@fago,
I'm working on adding property info for ER, some questions:
$this->definition['settings']['entity type'];
but in ER the value is in$this->definition['settings']['target_type'];
-- should I rename the keys?'settings' => array('id source' => 'value')
, as the source ID is infact chaned on the fly per delta (i.e. not even on the field level, but on the field values)Comment #5
fagoOk, so I try to give a summary of what needs to be done right now:
Comment #6
fagoYep, let's do so. This creates more dependencies on field type modules but as long as we've that modules I think we should have the implementations bundled there.
I'd prefer 'entity type' but I'm not keen on bikesheding this ;)
That's fine, the ER field keeps a referene on the 'id source' property so it will reflect any changes. However, what about having a separate type for revision references? API wise I'd prefer to have something like type => entity_revision - as it's quite different to a regular reference.
Comment #7
amitaibu> However, what about having a separate type for revision references?
The thing is that the same field on the same entity, can reference one time an entity by ID, and one time reference by revision ID. for example:
Comment #8
fagoIs that valuable to have in the same field?
But anyway, couldn't we still do 'entity_revision' as type and have
So even if you reference a revision ->entity would give you the active revision of the entity?
Comment #9
amitaibu> Is that valuable to have in the same field?
I guess this is something we need to figure out. The revision ID support doesn't exist yet in D7, so I don't have experience with it. I wonder if we should add a checkbox to the UI, saying "Use revision ID" -- in that case I don't even know how/ if we should show a widget.
I could start with a simpler implementation to deal only with the entity ID, and not with the revision ID, until we figure out how it should work.
Comment #10
yched CreditAttribution: yched commentedRe: 'entity type' :
Please keep in mind that with 'field types as plugins', all of these will be in annotations, so we should settle on underscore separated properties.
Comment #11
fagotrue. I wasn't aware of that restriction when writing the typed data api initially. I guess we'll have to migrate it to underscores, yeah.
Comment #12
yched CreditAttribution: yched commentedRight. Yaml keys in CMI files are another reason, actually.
Also, 'field types as plugins' means field type implementations will consist in providing one 'field type handler' class - which probably won't be the same as the 'field item (aka value)' class mentioned here. That would mean providing two classes for a field type.
Or is there a base 'field item' class that could be the same for most field types, and reference fields being the exception that needs to provide a dedicated item class ?
Comment #13
Berdir#1839070: Implement the new entity field API for the taxonomy reference field type now contains a working example of what needs to be done.
Note that this issue currently only covers the first step of this conversion. The whole thing is tracked in #1346214: [meta] Unified Entity Field API but doesn't list this issue yet. Once this is done and all entity types are converted to NG, we can start converting how we access these fields and also convert Field API itself. Then we can finally remove the BC layer :)
Comment #14
fagoI think we'll always need a custom field item class, as that's the one you are implementing for providing the defintition of contained properties/columns.
But as we discussed in Munich, I think we could base field types solely on the field-item classes. We could move everything more needed by field API into it for now (add another interface for the extensions), and then re-factor so that any possibly remaining duplicating functionality is unified.
Most problematic are probably the field-level crud hooks, but in the long term I think we could just replace them by computed properties and by moving the few modules that are using it to use entity-crud hooks instead.
Comment #15
yched CreditAttribution: yched commentedWell, precisely, providing the definition of contained properties/columns was not something I would have considered for the 'item' class, because you want that list in cases where you don't have an actual field value from an actual entity - like, to create the sql table on creation of the field.
There are also the methods that operate on multiple entities (like 'load', 'prepare_view'), and therefore on multiple items.
Well, I won't be focusing on "field types as plugins" before Dec 1st anyway, we'll have opportunities to discuss this :-)
Comment #15.0
yched CreditAttribution: yched commentedUpdated issue summary.
Comment #16
fagoYeah, let's discuss this more afterwards.
But note that it's perfectly fine to instantate field items without a value, so one can use the typedData API to derive information without nested properties without values. So that's not a problem. However yes, multiple-callbacks would not necessarily fit into that so well, so that's something we'd have to look at.
Comment #17
amitaibu@fago,
How do I get the field name in
getPropertyDefinitions()
?I expected that implementing
ContextAwareInterface
would be enough, however when I $this->getParent() I don't see the field name.Comment #18
fagoThere is getName() which gets you the name of a property, i.e. $entity->field->getName() gets you the field name.
Comment #19
amitaibuNo, I mean something else-- in EntityReferenceItem::getPropertyDefinitions() we currently have :
$entity_type = $this->definitions['settings']['entity type']
But this is of course not yet populated. The entity-type should be extracted from the field info, so I expected to do something like:
But even though I changed class
EntityReferenceItem
to extendContextAwareInterface
$this->getParent()
doesn't work.Comment #20
fagohm, the target-type is static information so I think it should be part of the definition always also. So what about adding it in via field_entity_field_info_alter() and add a todo to unify this keys? (If not the whole field-info)
Comment #21
amitaibufago pointed me to this -- http://api.drupal.org/api/drupal/core!modules!field!field.module/functio...
Comment #22
catchBumping status.
Comment #23
plachComment #23.0
plachUpdated issue summary.
Comment #23.1
Berdiradd telephone issue
Comment #24
arlinsandbulte CreditAttribution: arlinsandbulte commentedAn ignorant question:
Does this need to be done for the new Date field type too?
Comment #25
Berdirthe date field type already provides a DateItem class, the only thing that is missing are are unit tests for it I think like all other field types now have.
Comment #26
plachThe last issue in the OP was committed so I guess we can mark this fixed. Yay!
Comment #27
xjmYay!
Comment #28.0
(not verified) CreditAttribution: commentedUpdated issue summary.