You are here

protected function EntityGenerate::generateEntity in Migrate Plus 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate/process/EntityGenerate.php \Drupal\migrate_plus\Plugin\migrate\process\EntityGenerate::generateEntity()
  2. 8.2 src/Plugin/migrate/process/EntityGenerate.php \Drupal\migrate_plus\Plugin\migrate\process\EntityGenerate::generateEntity()
  3. 8.3 src/Plugin/migrate/process/EntityGenerate.php \Drupal\migrate_plus\Plugin\migrate\process\EntityGenerate::generateEntity()

Generates an entity for a given value.

Parameters

string $value: Value to use in creation of the entity.

Return value

int|string The entity id of the generated entity.

1 call to EntityGenerate::generateEntity()
EntityGenerate::transform in src/Plugin/migrate/process/EntityGenerate.php
Performs the associated process.

File

src/Plugin/migrate/process/EntityGenerate.php, line 131

Class

EntityGenerate
This plugin generates entities within the process plugin.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

protected function generateEntity($value) {
  if (!empty($value)) {
    $entity = $this->entityManager
      ->getStorage($this->lookupEntityType)
      ->create($this
      ->entity($value));
    $entity
      ->save();
    return $entity
      ->id();
  }
}