- Issue created by @Seb_R
Hi,
When I remove an entity from an entity reference field, where I have multiple entities referenced, the removed entity doesn't trigger
the USAGE_REGISTER event.
My goal is to add/remove media from a SolR index depending of their usage in the current revision of a published node.
So, when the node is updated, I need to use the USAGE_REGISTER event.
Add an entity reference field to a content type.
Create a node, and add some entities to that field.
When you remove one entity, when going in trackOnEntityUpdate, it calls trackOnEntityCreation and because the removed entity is not present anymore, the USAGE_REGISTER is not triggered.
in trackOnEntityUpdate
modify that test to check if field values are different between current entity and the original one?
If they are the same, go with trackOnEntityCreation, if not, continue with trackOnEntityUpdate.
if (($source_entity instanceof RevisionableInterface) &&
$source_entity->getRevisionId() != $source_entity->original->getRevisionId() &&
$source_entity->hasField($field_name) &&
!$source_entity->{$field_name}->isEmpty()
)
I can try to work on this, but I need to be sure I don't miss something else.
Any idea?
Thanks.
Have a good day,
Seb
Active
Code