class D7FieldGroupDeriver in Field Group 8.3
Derives Drupal 7 field group migrations per entity type and bundle.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\field_group_migrate\Plugin\migrate\D7FieldGroupDeriver uses StringTranslationTrait, MigrationDeriverTrait
Expanded class hierarchy of D7FieldGroupDeriver
1 string reference to 'D7FieldGroupDeriver'
- d7_field_group.yml in contrib/
field_group_migrate/ migrations/ d7_field_group.yml - contrib/field_group_migrate/migrations/d7_field_group.yml
File
- contrib/
field_group_migrate/ src/ Plugin/ migrate/ D7FieldGroupDeriver.php, line 17
Namespace
Drupal\field_group_migrate\Plugin\migrateView source
class D7FieldGroupDeriver extends DeriverBase {
use MigrationDeriverTrait;
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$field_group_source = static::getSourcePlugin('d7_field_group');
try {
$field_group_source
->checkRequirements();
} catch (RequirementsException $e) {
// The requirements of the "d7_field_group" source plugin can fail if:
// - The source database is not configured or it isn't a Drupal 7 DB.
// - The Field Group module is not enabled on the source Drupal instance.
return $this->derivatives;
}
assert($field_group_source instanceof DrupalSqlBase);
try {
foreach ($field_group_source as $field_group_row) {
assert($field_group_row instanceof Row);
[
'entity_type' => $entity_type,
'bundle' => $bundle,
] = $field_group_row
->getSource();
$derivative_id = implode(PluginBase::DERIVATIVE_SEPARATOR, [
$entity_type,
$bundle,
]);
if (!empty($this->derivatives[$derivative_id])) {
continue;
}
$derivative_definition = $base_plugin_definition;
$derivative_definition['source']['entity_type'] = $entity_type;
$derivative_definition['source']['bundle'] = $bundle;
$derivative_definition['label'] = $this
->t('@label of @entity_type (bundle: @bundle)', [
'@label' => $derivative_definition['label'],
'@entity_type' => $entity_type,
'@bundle' => $bundle,
]);
$this->derivatives[$derivative_id] = $derivative_definition;
}
} 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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
D7FieldGroupDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
MigrationDeriverTrait:: |
public static | function | Returns a fully initialized instance of a source plugin. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |