You are here

protected function MicrositePluginTrait::getFieldOptions in Entity Reference Hierarchy 8.2

Same name and namespace in other branches
  1. 3.x modules/entity_hierarchy_microsite/src/Plugin/MicrositePluginTrait.php \Drupal\entity_hierarchy_microsite\Plugin\MicrositePluginTrait::getFieldOptions()

Gets field options.

Return value

array Field names keyed by label.

2 calls to MicrositePluginTrait::getFieldOptions()
ChildOfMicrosite::summary in modules/entity_hierarchy_microsite/src/Plugin/Condition/ChildOfMicrosite.php
Provides a human readable summary of the condition's configuration.
MicrositePluginTrait::buildConfigurationForm in modules/entity_hierarchy_microsite/src/Plugin/MicrositePluginTrait.php

File

modules/entity_hierarchy_microsite/src/Plugin/MicrositePluginTrait.php, line 101

Class

MicrositePluginTrait
Defines a trait for microsite plugin functionality.

Namespace

Drupal\entity_hierarchy_microsite\Plugin

Code

protected function getFieldOptions() {
  $fields = $this->entityFieldManager
    ->getFieldMapByFieldType('entity_reference_hierarchy');
  $options = [];
  if (isset($fields['node'])) {
    foreach ($fields['node'] as $field_name => $detail) {
      foreach ($detail['bundles'] as $bundle) {

        /** @var \Drupal\Core\Field\FieldDefinitionInterface $field */
        $field = $this->entityFieldManager
          ->getFieldDefinitions('node', $bundle)[$field_name];
        $options[$field_name] = $field
          ->getLabel();
      }
    }
  }
  return $options;
}