You are here

function sharemessage_entity_extra_field_info in Share Message 8

Implements hook_entity_extra_field_info().

File

./sharemessage.module, line 254
New Sharing Module.

Code

function sharemessage_entity_extra_field_info() {
  $extra = [];

  /** @var \Drupal\sharemessage\ShareMessageInterface $sharemessage_storage */
  $sharemessage_storage = \Drupal::entityTypeManager()
    ->getStorage('sharemessage');
  foreach ($sharemessage_storage
    ->loadMultiple() as $sharemessage) {
    $entity_type = $sharemessage
      ->getExtraFieldEntityType();
    if ($entity_type) {

      // Expose the Share Message extra field.
      $bundles = $sharemessage
        ->getExtraFieldBundles();
      if (!$bundles) {
        $bundles = array_keys(\Drupal::service('entity_type.bundle.info')
          ->getBundleInfo($entity_type));
      }
      foreach ($bundles as $bundle) {
        $extra[$entity_type][$bundle] = [
          'display' => [
            'sharemessage__' . $sharemessage
              ->id() => [
              'label' => $sharemessage
                ->label(),
              'visible' => FALSE,
            ],
          ],
        ];
      }
    }
  }
  return $extra;
}