You are here

function entity_print_entity_extra_field_info in Entity Print 8.2

Implements hook_entity_extra_field_info().

File

./entity_print.module, line 47
Print any entity.

Code

function entity_print_entity_extra_field_info() {
  $export_types = \Drupal::service('plugin.manager.entity_print.export_type')
    ->getDefinitions();
  $bundle_info = \Drupal::service('entity_type.bundle.info')
    ->getAllBundleInfo();
  $extra_fields = [];
  foreach ($bundle_info as $entity_type_id => $bundles) {
    foreach ($bundles as $bundle_id => $bundle) {
      foreach ($export_types as $export_type => $definition) {
        $extra_fields[$entity_type_id][$bundle_id]['display']['entity_print_view_' . $export_type] = [
          'label' => t('View @label', [
            '@label' => $definition['label'],
          ]),
          'description' => t('Provides a link to view the Print version of the entity'),
          'weight' => 0,
          'visible' => FALSE,
        ];
      }
    }
  }
  return $extra_fields;
}