Problem/Motivation

We have altered the cloning form (entity_clone_form), adding some extra parameters (in our case the entity clone language).

We can use these extra settings during clone using EntityCloneEvents::PRE_CLONE or EntityCloneEvents::POST_CLONE.

But these events are dispatched only when the first node is cloned. Child nodes which are cloned using cloneReferencedEntities function don't dispatch events.

It should be very useful if also when we clone child nodes the same events will be dispatched.

Comments

eithel created an issue. See original summary.

eithel’s picture

I've upload a patch for this issue

eithel’s picture

Issue summary: View changes
lamp5’s picture

Status: Active » Reviewed & tested by the community

Works perfect!

colan’s picture

Version: 8.x-1.0-beta3 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Needs work
+++ b/src/EntityClone/Content/ContentEntityCloneBase.php
@@ -31,18 +34,24 @@ class ContentEntityCloneBase implements EntityHandlerInterface, EntityCloneInter
+	/**
+	 * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
+	 */
+	protected $event_dispatcher;
+
+	/**
+	 * Constructs a new ContentEntityCloneBase.
+	 *
+	 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+	 *   The entity type manager.
+	 * @param string $entity_type_id
+	 *   The entity type ID.
+	 * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
+	 */

Tabs are being used here instead of spaces, which doesn't follow the coding standards.

lamp5’s picture

Status: Needs work » Needs review
StatusFileSize
new3.49 KB
lamp5’s picture

upchuk’s picture

StatusFileSize
new11.91 KB

Improved a bit the patch by allowing the event to receive both the top-level properties and the child properties.

I also added test coverage.

joevagyok’s picture

Status: Needs review » Reviewed & tested by the community

Tested and reviewed. Moving it to RTBC.

sinn’s picture

Patch #8 works well.

lamp5’s picture

StatusFileSize
new11.86 KB

reroll

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 11: entity_clone-3089105-11.patch, failed testing. View results

jonathanshaw’s picture

Status: Needs work » Closed (duplicate)

Closing as a duplicate of #3058025: Add PRE_CLONE/POST_CLONE event dispatch handling to sub referenced entities and moving the test to there. Will ask maintainer to transfer credit to.