You are here

public function BulkCloneNode::execute in Entity Bulk Clone 8

Executes the plugin.

Overrides ExecutableInterface::execute

1 call to BulkCloneNode::execute()
BulkCloneNode::executeMultiple in src/Plugin/Action/BulkCloneNode.php
Executes the plugin for an array of objects.

File

src/Plugin/Action/BulkCloneNode.php, line 58

Class

BulkCloneNode
Entity Bulk clone of nodes.

Namespace

Drupal\entity_bulk_clone\Plugin\Action

Code

public function execute($entity = NULL) {
  $replicator = \Drupal::service('replicate.replicator');
  $duplicate_entity = $replicator
    ->replicateByEntityId($entity
    ->getEntityTypeId(), $entity
    ->id());
  $title = $duplicate_entity
    ->getTitle();
  $duplicate_entity
    ->setTitle($title . ' - Bulk Cloned');
  $request_time = \Drupal::time()
    ->getRequestTime();
  $duplicate_entity
    ->setChangedTime($request_time);
  $duplicate_entity
    ->save();
}