addEntityFieldProcesses example

$this->migrationPluginManager = $migration_plugin_manager;
    $this->logger = $logger;
  }

  /** * {@inheritdoc} */
  public function addAllFieldProcesses(MigrationInterface $migration) {
    $core = $this->getCoreVersion($migration);
    $fields = $this->getAllFields($core);
    foreach ($fields as $entity_type_id => $bundle) {
      $this->addEntityFieldProcesses($migration$entity_type_id);
    }
  }

  /** * {@inheritdoc} */
  public function addEntityFieldProcesses(MigrationInterface $migration$entity_type_id) {
    $core = $this->getCoreVersion($migration);
    $fields = $this->getAllFields($core);
    if (!empty($fields[$entity_type_id])  && is_array($fields[$entity_type_id])) {
      foreach ($fields[$entity_type_id] as $bundle => $fields) {
        
/** * Migration plugin for Drupal 7 comments with fields. */
class D7Comment extends FieldMigration {

  /** * {@inheritdoc} */
  public function getProcess() {
    if (!$this->init) {
      $this->init = TRUE;
      $this->fieldDiscovery->addEntityFieldProcesses($this, 'comment');
    }
    return parent::getProcess();
  }

}
/** * Plugin class for Drupal 7 user migrations dealing with fields and profiles. */
class User extends FieldMigration {

  /** * {@inheritdoc} */
  public function getProcess() {
    if (!$this->init) {
      $this->init = TRUE;
      $this->fieldDiscovery->addEntityFieldProcesses($this, 'user');

      $definition = [
        'source' => [
          'plugin' => 'profile_field',
          'ignore_map' => TRUE,
        ],
        'idMap' => [
          'plugin' => 'null',
        ],
        'destination' => [
          'plugin' => 'null',
        ],

  public function assertFieldProcess(FieldDiscoveryInterface $field_discovery, MigrationPluginManagerInterface $migration_plugin_manager$core$field_plugin_method = NULL, array $expected_process = []$entity_type_id = NULL, $bundle = NULL) {
    $definition = [
      'migration_tags' => ['Drupal ' . $core],
      'field_plugin_method' => $field_plugin_method,
    ];
    $migration = $migration_plugin_manager->createStubMigration($definition);
    if ($bundle) {
      $field_discovery->addBundleFieldProcesses($migration$entity_type_id$bundle);
    }
    elseif ($entity_type_id) {
      $field_discovery->addEntityFieldProcesses($migration$entity_type_id);
    }
    else {
      $field_discovery->addAllFieldProcesses($migration);
    }
    $actual_process = $migration->getProcess();
    $this->assertSame($expected_process$actual_process);
  }

  /** * Asserts the field discovery returns the expected processes. * * @param \Drupal\migrate_drupal\FieldDiscoveryInterface $field_discovery * The Field Discovery service. * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager * The migration plugin manager service. * @param string $core * The Drupal core version, either '6', or '7'. * @param array $expected_process_keys * (optional) The expected resulting process_keys. * @param string $entity_type_id * (optional) The entity type id. * @param string $bundle * (optional) The bundle. */
Home | Imprint | This part of the site doesn't use cookies.