public function MediaWysiwygPluginBase::__construct in Media Migration 8
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 PluginBase::__construct
File
- src/
MediaWysiwygPluginBase.php, line 22
Class
- MediaWysiwygPluginBase
- Base class for media_wysiwyg plugins.
Namespace
Drupal\media_migrationCode
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
$source_entity_type_id = $configuration['source_entity_type_id'] ?? NULL;
if (!$source_entity_type_id && count($plugin_definition['entity_type_map']) === 1) {
$source_entity_type_id_keys = array_keys($plugin_definition['entity_type_map']);
$configuration['source_entity_type_id'] = reset($source_entity_type_id_keys);
}
if (empty($configuration['source_entity_type_id']) || empty($plugin_definition['entity_type_map'][$configuration['source_entity_type_id']])) {
throw new PluginException(sprintf("The MediaWysiwyg plugin instance of class '%s' cannot be instantiated with the following configuration: %s", get_class($this), Variable::export($configuration)));
}
$configuration += [
'destination_entity_type_id' => $plugin_definition['entity_type_map'][$configuration['source_entity_type_id']],
];
parent::__construct($configuration, $plugin_id, $plugin_definition);
}