public function D7ParagraphsItemDeriver::getDerivativeDefinitions in Paragraphs 8
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- src/
Plugin/ migrate/ D7ParagraphsItemDeriver.php, line 62
Class
- D7ParagraphsItemDeriver
- Deriver for Paragraph Items.
Namespace
Drupal\paragraphs\Plugin\migrateCode
public function getDerivativeDefinitions($base_plugin_definition) {
$types = static::getSourcePlugin('d7_paragraphs_type');
try {
$types
->checkRequirements();
} catch (RequirementsException $e) {
return $this->derivatives;
}
try {
foreach ($types as $row) {
$values = $base_plugin_definition;
$bundle = $row
->getSourceProperty('bundle');
$values['label'] = $this
->t('@label (@type)', [
'@label' => $values['label'],
'@type' => $row
->getSourceProperty('name'),
]);
$values['source']['bundle'] = $bundle;
$values['destination']['default_bundle'] = $bundle;
/** @var \Drupal\migrate\Plugin\Migration $migration */
$migration = \Drupal::service('plugin.manager.migration')
->createStubMigration($values);
$this->fieldDiscovery
->addBundleFieldProcesses($migration, 'paragraphs_item', $bundle);
$this->derivatives[$bundle] = $migration
->getPluginDefinition();
}
} catch (DatabaseExceptionWrapper $e) {
// Once we begin iterating the source plugin it is possible that the
// source tables will not exist. This can happen when the
// MigrationPluginManager gathers up the migration definitions but we do
// not actually have a Drupal 7 source database.
}
return $this->derivatives;
}