You are here

public function MappingEditForm::getAllEntityReferenceFields in GatherContent 8.3

Get list of entity reference fields with mapping to GatherContent.

2 calls to MappingEditForm::getAllEntityReferenceFields()
MappingEditForm::form in src/Form/MappingEditForm.php
Gets the actual form array to be built.
MappingEditForm::getMappingTable in src/Form/MappingEditForm.php
Ajax callback for mapping multistep form.

File

src/Form/MappingEditForm.php, line 982

Class

MappingEditForm
Class MappingEditForm.

Namespace

Drupal\gathercontent\Form

Code

public function getAllEntityReferenceFields() {
  $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') {
      $entityReferenceFields[] = $instance
        ->getName();
    }
  }
  return $entityReferenceFields;
}