You are here

function addtoany_entity_extra_field_info in AddToAny Share Buttons 8

Implements hook_entity_extra_field_info().

File

./addtoany.module, line 60
Handle AddToAny integration.

Code

function addtoany_entity_extra_field_info() {
  $extra = [];
  $entityTypes = AddToAnySettingsForm::getContentEntities();
  $config = Drupal::config('addtoany.settings');

  // Allow modules to alter the entity types.
  \Drupal::moduleHandler()
    ->alter('addtoany_entity_types', $entityTypes);
  foreach ($entityTypes as $type) {
    $entityTypeId = $type
      ->id();
    $isAllowed = $config
      ->get("entities.{$entityTypeId}");
    if ($isAllowed) {
      $bundles = Drupal::service('entity_type.bundle.info')
        ->getBundleInfo($entityTypeId);
      foreach ($bundles as $bundle => $bundle_data) {
        $extra[$entityTypeId][$bundle]['display']['addtoany'] = [
          'label' => t('AddToAny'),
          'description' => t('Share buttons by AddToAny'),
          'weight' => 5,
          'visible' => FALSE,
        ];
      }
    }
  }
  return $extra;
}