public function Yaml::__construct in Migrate Source YAML 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 SourcePluginBase::__construct
File
- src/
Plugin/ migrate/ source/ Yaml.php, line 49
Class
- Yaml
- Migrate source plugin for Yaml.
Namespace
Drupal\migrate_source_yaml\Plugin\migrate\sourceCode
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
// Path is required.
if (empty($this->configuration['file'])) {
throw new MigrateException('You must declare the "file" to the source Yaml file in your source settings.');
}
// ID field(s) are required.
if (empty($this->configuration['ids'])) {
throw new MigrateException('You must declare "ids" as a unique array of fields in your source settings.');
}
try {
$this->dataRows = YamlComponent::parse(file_get_contents($configuration['file']));
} catch (ParseException $exc) {
\Drupal::logger('Migrate source Yaml')
->error('Failed to parse source file @file', [
'@file' => $configuration['file'],
]);
}
$this->ids = $configuration['ids'];
}