- Issue created by @steven jones
- last update
over 1 year ago 7 pass - @steven-jones opened merge request.
- Status changed to Needs review
over 1 year ago 2:33pm 6 October 2023
I'm not sure if this is a feature or a bug, but in: \Drupal\replicate\Replicator::cloneEntity
we have:
public function cloneEntity(EntityInterface $entity) {
if ($clone = $entity->createDuplicate()) {
$event = new ReplicateEntityEvent($entity);
$this->eventDispatcher->dispatch($event, ReplicatorEvents::replicateEntityEvent($entity->getEntityTypeId()));
if ($clone instanceof FieldableEntityInterface) {
/** @var FieldableEntityInterface $clone */
$this->dispatchEventCloneEntityFields($clone);
}
$event = new ReplicateAlterEvent($clone, $entity);
$this->eventDispatcher->dispatch($event, ReplicatorEvents::REPLICATE_ALTER);
return $clone;
}
}
The rough summary is:
But note how the second step passes in A and not B, so anyone implementing this event ends up frustrated because they can't do much. The only thing I could think that you could do is throw an exception?
I don't think that's the intended use-case here, and humbly suggest this is a bug.
Replicate an entity.
Fix the bug.
Write a patch, test it.
None.
The replicated entity will be passed to the event.
None.
Needs review
1.0
Code