You are here

public function ExtraFieldDisplayManager::fieldInfo in Extra Field 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/ExtraFieldDisplayManager.php \Drupal\extra_field\Plugin\ExtraFieldDisplayManager::fieldInfo()

Exposes the ExtraFieldDisplay plugins to hook_entity_extra_field_info().

Return value

array The array structure is identical to that of the return value of \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields().

Overrides ExtraFieldDisplayManagerInterface::fieldInfo

See also

hook_entity_extra_field_info()

File

src/Plugin/ExtraFieldDisplayManager.php, line 58

Class

ExtraFieldDisplayManager
Manages Extra Field plugins.

Namespace

Drupal\extra_field\Plugin

Code

public function fieldInfo() {
  $info = [];
  $definitions = $this
    ->getDefinitions();
  foreach ($definitions as $key => $definition) {
    $entityBundles = $this
      ->supportedEntityBundles($definition['bundles']);
    foreach ($entityBundles as $entityBundle) {
      $entityType = $entityBundle['entity'];
      $bundle = $entityBundle['bundle'];
      $fieldName = $this
        ->fieldName($key);
      $info[$entityType][$bundle]['display'][$fieldName] = [
        'label' => $definition['label'],
        'weight' => $definition['weight'],
        'visible' => $definition['visible'],
      ];
    }
  }
  return $info;
}