I've defined a shadowing callbacking in the entity-level properties map, e.g.
// We want to populate field_dc_description from remote description.
'field_dc_description' => array(
'type' => 'text',
'description' => 'Description of metadata record.',
'remote property shadowing' => array(
'remote to local callback' => 'fedoraentity_collection_shadow_remote_to_local',
),
),
but it doesn't get invoked. Looking at the logic in RemoteEntityAPIDefaultMetadataController->entityPropertyInfo() it's not clear that the 'remote property shadowing' key and associated data is ever passed through into the properties array for use in pack() and unpack().
Is this a bug or have I misinterpreted the documentation (see #2407659: More examples, documentation)?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | remote_entity_shadowing_for_fieldapi_fields-2407677-5.patch | 637 bytes | jonathan_hunt |
Comments
Comment #1
jonathan_hunt commentedComment #2
jonathan_hunt commentedOk, I mis-interpreted the docs. Instead of being a key on the entity-level properties map, shadowing can be specified via fedoraentity_entity_property_info_alter(). For example:
This successfully populates the title and field_dc_description values into the first level of the entity array but it *doesn't* populate the default value of the field_dc_description (Field API field).
Comment #3
joachim commented> Does shadowing work for Field API fields?
As you've found, yes it does :)
> field_dc_description values into the first level of the entity array but it *doesn't* populate the default value of the field_dc_description (Field API field).
Do you mean that when you retrieve a remote entity and the 'description' remote property is empty, the locally-created entity doesn't get the default value for the field_dc_description that is set in Field admin? If you don't have the shadowing set, does that default value get set correctly?
Comment #4
jonathan_hunt commentedTo be clear, after importing an entity from remote, with shadowing per #2 the data structure is:
The shadowing callback has pulled title and description from entity_data but written them to the first level of the entity object. That's ok for title, since title is declared as a local property. But it is no good for field_dc_description which is a Field API text field. I would have expected field_dc_description to look more like
The field_dc_description value is not visible on entity view or edit pages.
This is why I asked whether shadowing works for Field API fields...
Comment #5
jonathan_hunt commentedSetting the incoming value on the entity wrapper rather than the entity directly works for properties and Field API fields.
Comment #7
joachim commentedGood catch!
(Ignore the test result; d.org testbot doesn't seem to like this module, I've just run the tests locally and they all pass.)
Committed. Thanks!