public function MappingEditForm::getEntityReferenceFields in GatherContent 8.3
Get list of entity reference fields with mapping to GatherContent.
1 call to MappingEditForm::getEntityReferenceFields()
- MappingEditForm::submitForm in src/
Form/ MappingEditForm.php - This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
File
- src/
Form/ MappingEditForm.php, line 954
Class
- MappingEditForm
- Class MappingEditForm.
Namespace
Drupal\gathercontent\FormCode
public function getEntityReferenceFields() {
$this->entityReferenceFields = [];
/** @var \Drupal\Core\Field\FieldDefinitionInterface[] $instances */
$instances = \Drupal::service('entity_field.manager')
->getFieldDefinitions('node', $this->contentType);
foreach ($instances as $instance) {
if ($instance
->getType() === 'entity_reference' && $instance
->getSetting('handler') === 'default:taxonomy_term') {
foreach ($this->mappingData as $tabName => $tab) {
$gcField = array_search($instance
->getName(), $tab['elements']);
if (empty($gcField)) {
continue 2;
}
if (isset($tab['language'])) {
$this->entityReferenceFields[$instance
->getName()][$tab['language']]['name'] = $gcField;
$this->entityReferenceFields[$instance
->getName()][$tab['language']]['tab'] = $tabName;
}
else {
$this->entityReferenceFields[$instance
->getName()][LanguageInterface::LANGCODE_NOT_SPECIFIED]['name'] = $gcField;
$this->entityReferenceFields[$instance
->getName()][LanguageInterface::LANGCODE_NOT_SPECIFIED]['tab'] = $tabName;
}
}
}
}
}