protected function DrupalMigrationGenerator::termField in Drupal-to-Drupal data migration 8.3
Returns the first field referencing a given vocabulary.
Parameters
string $bundle:
string $vocabulary:
Return value
string
1 call to DrupalMigrationGenerator::termField()
- DrupalMigrationGenerator::createContentMigration in src/
DrupalMigrationGenerator.php - Setup the migration for a given WordPress content type.
File
- src/
DrupalMigrationGenerator.php, line 238
Class
- DrupalMigrationGenerator
- Functionality to construct Drupal migrations from broad configuration settings.
Namespace
Drupal\migrate_d2dCode
protected function termField($bundle, $vocabulary) {
/** @var \Drupal\Core\Field\FieldDefinitionInterface[] $all_fields */
$all_fields = \Drupal::service('entity_field.manager')
->getFieldDefinitions('node', $bundle);
foreach ($all_fields as $field_name => $field_definition) {
if ($field_definition
->getType() == 'entity_reference') {
$storage = $field_definition
->getFieldStorageDefinition();
if ($storage
->getSetting('target_type') == 'taxonomy_term') {
$handler_settings = $field_definition
->getSetting('handler_settings');
if (isset($handler_settings['target_bundles'][$vocabulary])) {
return $field_name;
}
}
}
}
return '';
}