function FieldDiscovery::addBundleFieldProcesses

Same name in other branches
  1. 9 core/modules/migrate_drupal/src/FieldDiscovery.php \Drupal\migrate_drupal\FieldDiscovery::addBundleFieldProcesses()
  2. 8.9.x core/modules/migrate_drupal/src/FieldDiscovery.php \Drupal\migrate_drupal\FieldDiscovery::addBundleFieldProcesses()
  3. 11.x core/modules/migrate_drupal/src/FieldDiscovery.php \Drupal\migrate_drupal\FieldDiscovery::addBundleFieldProcesses()
1 call to FieldDiscovery::addBundleFieldProcesses()
FieldDiscovery::addEntityFieldProcesses in core/modules/migrate_drupal/src/FieldDiscovery.php

File

core/modules/migrate_drupal/src/FieldDiscovery.php, line 135

Class

FieldDiscovery
Provides field discovery for Drupal 6 & 7 migrations.

Namespace

Drupal\migrate_drupal

Code

public function addBundleFieldProcesses(MigrationInterface $migration, $entity_type_id, $bundle) {
    $core = $this->getCoreVersion($migration);
    $fields = $this->getAllFields($core);
    $plugin_definition = $migration->getPluginDefinition();
    if (empty($fields[$entity_type_id][$bundle])) {
        return;
    }
    $bundle_fields = $fields[$entity_type_id][$bundle];
    foreach ($bundle_fields as $field_name => $field_info) {
        $plugin = $this->getFieldPlugin($field_info['type'], $migration);
        if ($plugin) {
            $method = $plugin_definition['field_plugin_method'] ?? 'defineValueProcessPipeline';
            call_user_func_array([
                $plugin,
                $method,
            ], [
                $migration,
                $field_name,
                $field_info,
            ]);
        }
        else {
            // Default to a get process plugin if this is a value migration.
            if (empty($plugin_definition['field_plugin_method']) || $plugin_definition['field_plugin_method'] === 'defineValueProcessPipeline') {
                $migration->setProcessOfProperty($field_name, $field_name);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.