You are here

public function ExtraFieldDisplayManager::fieldInfo in Extra Field 8.2

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

Exposes the ExtraField 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 ExtraFieldManagerBase::fieldInfo

See also

hook_entity_extra_field_info()

File

src/Plugin/ExtraFieldDisplayManager.php, line 75

Class

ExtraFieldDisplayManager
Manages Extra Field display plugins.

Namespace

Drupal\extra_field\Plugin

Code

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