function MigrationPluginManager::processDefinition

Performs extra processing on plugin definitions.

By default we add defaults for the type to the definition. If a type has additional processing logic they can do that by replacing or extending the method.

Overrides DefaultPluginManager::processDefinition

File

core/modules/migrate_drupal/src/MigrationPluginManager.php, line 87

Class

MigrationPluginManager
Manages migration plugins.

Namespace

Drupal\migrate_drupal

Code

public function processDefinition(&$definition, $plugin_id) {
  parent::processDefinition($definition, $plugin_id);
  $source_id = $definition['source']['plugin'];
  $source_definition = $this->sourceManager
    ->getDefinition($source_id);
  // If the source plugin uses annotations, then the 'provider' key is the
  // array of providers. If the source plugin uses attributes, then combine
  // the singular string provider with the providers for the plugin
  // dependencies.
  if (is_array($source_definition['provider'])) {
    $providers = $source_definition['provider'];
  }
  else {
    $providers = $source_definition['dependencies']['provider'] ?? [];
    $providers[] = $source_definition['provider'];
  }
  // Check if the migration has any of the tags that trigger source_module
  // enforcement.
  $has_enforced_tags = !empty(array_intersect($definition['migration_tags'] ?? [], $this->getEnforcedSourceModuleTags()));
  // If source_module is not defined in the migration, then check for it in
  // the source plugin.
  $has_source_module = !empty($definition['source']['source_module']) || !empty($source_definition['source_module']);
  $requires_migrate_drupal = in_array('migrate_drupal', $providers, TRUE);
  if ($requires_migrate_drupal && $has_enforced_tags && !$has_source_module) {
    throw new BadPluginDefinitionException($source_id, 'source_module');
  }
  if (!$requires_migrate_drupal && !$has_enforced_tags && $has_source_module) {
    @trigger_error("Setting the source_module property without the expected tags is deprecated in drupal:11.2.0 and will trigger an error in drupal:12.0.0. See https://www.drupal.org/node/3306373", E_USER_DEPRECATED);
  }
}

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