replicate_actions
While Replicating Nodes using Replicate API and Replicate UI modules, I found that the module will publish a node immediately (shows "view" mode) after replication.
What I would like is for when the replicated a node opens in edit mode so that a content manager can make the necessary changes before publishing it. Otherwise, it creates too many steps for them to go through.
For now, the module makes replicated entities unpublished and makes a redirect to edit mode.
Also, if the Group module is installed, this module checks whether a node has been added to a group and does exactly that.
In the future, incoming versions, I am going to add new functionality and allow doing the same for other entity types and some more actions.
This provides the extension for a simple but powerful Replicate UI.
The full list of what it module does
Unpublish replicated entities
- Trigger:
ReplicatorEvents::REPLICATE_ALTER. - Applies to publishable content entities that have a
statusfield. - Skips:
- Paragraph entities (
paragraph). - Non‑reusable Layout Builder custom blocks (
block_contentthat are not reusable).
- Paragraph entities (
- For all translations:
- Sets status to unpublished.
- Resets created/changed timestamps to the current time (when supported).
- Implementation:
src/EventSubscriber/ReplicateSetUnpublished.php(service:replicate_actions.replicate_entity_unpublish).
Set the owner of the replicated entity to the current user
- Trigger:
ReplicatorEvents::REPLICATE_ALTER. - For each translation, if the entity supports ownership (
setOwnerId), sets the owner to the logged‑in user. - Implementation:
src/EventSubscriber/ReplicateSetAuthor.php(service:replicate_actions.replicate_set_author).
Redirect to the edit form after replication (Replicate UI)
- Alters the Replicate UI confirm form to redirect to the new entity’s edit form after submission.
- Only redirects if the entity has an
edit-formlink template. - Implementation:
src/Form/ReplicateFormAlter.phpused viahook_form_alter()inreplicate_actions.module(service:replicate_actions.replicate_form_alter).
Copy Group memberships for nodes (if Group module is enabled)
- Stores the original node ID during
REPLICATE_ALTER, then, after save (AFTER_SAVE), adds the cloned node to the same Groups as the original. - Only runs for nodes and only when the
groupmodule is installed. - Uses group content plugin ID
group_node:{bundle}when adding the relationship. - Implementation:
src/EventSubscriber/ReplicateNodeToGroup.php(service:replicate_actions.replicate_node_to_group).
Constraints and exclusions
- Paragraph entities are not auto‑unpublished.
- Non‑reusable custom blocks from Layout Builder are not auto‑unpublished.
- Group copying applies only to nodes and requires the Group module.
- Owner change runs only if the entity supports ownership (
setOwnerId).
Files of interest
replicate_actions.info.yml— Declares the module; depends onreplicateandreplicate_ui.replicate_actions.services.yml— Registers the form alter and event subscribers.replicate_actions.module— Containshook_help()andhook_form_alter().- Implementations under
src/:EventSubscriber/ReplicateSetUnpublished.phpEventSubscriber/ReplicateSetAuthor.phpEventSubscriber/ReplicateNodeToGroup.phpForm/ReplicateFormAlter.php
🇺🇦
This module is maintained by Ukrainian developers.Please consider supporting Ukraine in the fight for their freedom and the safety of Europe.