Problem/Motivation
Is it possible to map DAM metadata to Drupal entity reference field or mapping is supported only for text or number fields ? Currently it is working only for text fields but not for entity reference fields for me.
Issue fork acquia_dam-3443757
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nikhilesh gupta commentedComment #3
agentrickardWe are also looking at this and it does not appear to be supported, so marking as a Feature Request.
Comment #4
agentrickardSo the current metadata refresh looks pretty simple. See
MetadataRefreshTrait::forceMappedFieldRefresh.We should be able to adapt that method a bit to account for entity reference fields. The problem here is that we have to register field lookups.
Consider this case:
This is all pretty simple if we assume that the Entity Reference is a taxonomy term, but I am not sure that is a safe assumption.
What I would propose is adding an event to the trait which allows for a data lookup on the Drupal side before we resolve the call to
$translation->set($entity_field_name, $media_source->getMetadata($translation, $metadata_attribute_name));Something like this:
That should provide enough metadata to derive the entity lookup.
I would propose that we:
Comment #5
agentrickardComment #6
agentrickardI am not going to have immediate time to pursue this, but here is a patch for testing. It does the following:
I started to write default event handlers, but that gets tricky, so it seems "good enough" to allow developers to write their own Event handlers to respond to the metadata update.
Comment #7
mahesh bandhiya commentedRerolled the patch to update according to the latest changes in AssetUpdateChecker QueueWorker.
Comment #8
mahesh bandhiya commentedThere might be a possibility when custom implementation where we require the metadata attribute name in the event handler, i have added an extra argument for this.
Comment #9
japerrybefore pushing this up, we need this to be put into an MR and corresponding tests added.
Comment #12
rajeshreeputraCreated MR, please review. Code coverage will be added soon.
Comment #14
rajeshreeputraMR merged!