function drush_replicate_drush_entity_by_ids in Replicate 8
Same name and namespace in other branches
- 7 replicate.drush.inc \drush_replicate_drush_entity_by_ids()
Command callback to replicate entities.
File
- ./
replicate.drush.inc, line 44 - Replicate entities via drush framework.
Code
function drush_replicate_drush_entity_by_ids($entity_type = NULL, $ids = NULL) {
$original_ids = explode(',', $ids);
/** @var \Drupal\replicate\Replicator $replicator */
$replicator = \Drupal::service('replicate.replicator');
foreach ($original_ids as $original_id) {
$entity = $replicator
->replicateByEntityId($entity_type, $original_id);
if (!empty($entity)) {
drush_log(dt('@entity_type @entity_id is clone of @entity_type @original_id', [
'@entity_type' => $entity_type,
'@entity_id' => $entity
->id(),
'@original_id' => (int) $original_id,
]), 'success');
}
else {
drush_log(dt('Impossible to replicate @entity_type @original_id', [
'@entity_type' => $entity_type,
'@original_id' => $original_id,
]), 'error');
}
}
}