public function DomMigrationLookup::__construct in Migrate Plus 8.5
Constructs a \Drupal\Component\Plugin\PluginBase object.
Parameters
array $configuration: A configuration array containing information about the plugin instance.
string $plugin_id: The plugin_id for the plugin instance.
mixed $plugin_definition: The plugin implementation definition.
Overrides DomStrReplace::__construct
File
- src/
Plugin/ migrate/ process/ DomMigrationLookup.php, line 96
Class
- DomMigrationLookup
- String replacements on a source dom based on migration lookup.
Namespace
Drupal\migrate_plus\Plugin\migrate\processCode
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigratePluginManagerInterface $process_plugin_manager) {
$configuration += [
'no_stub' => TRUE,
];
$default_replace_missing = empty($configuration['replace']);
if ($default_replace_missing) {
$configuration['replace'] = 'prevent-requirement-fail';
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
if ($default_replace_missing) {
unset($this->configuration['replace']);
}
$this->migration = $migration;
$this->processPluginManager = $process_plugin_manager;
if (empty($this->configuration['migrations'])) {
throw new InvalidPluginDefinitionException($this
->getPluginId(), "Configuration option 'migration' is required.");
}
if (!is_array($this->configuration['migrations'])) {
throw new InvalidPluginDefinitionException($this
->getPluginId(), "Configuration option 'migration' should be a keyed array.");
}
// Add missing values if possible.
$default_replace = isset($this->configuration['replace']) ? $this->configuration['replace'] : NULL;
foreach ($this->configuration['migrations'] as $migration_name => $configuration_item) {
if (!empty($configuration_item['replace'])) {
continue;
}
if (is_null($default_replace)) {
throw new InvalidPluginDefinitionException($this
->getPluginId(), "Please define either a global replace for all migrations, or a specific one for 'migrations.{$migration_name}'.");
}
$this->configuration['migrations'][$migration_name]['replace'] = $default_replace;
}
}