You are here

entity_print_views.module in Entity Print 8.2

Same filename and directory in other branches
  1. 7 modules/entity_print_views/entity_print_views.module

Entity Print Views module file.

File

modules/entity_print_views/entity_print_views.module
View source
<?php

/**
 * @file
 * Entity Print Views module file.
 */
use Drupal\entity_print_views\Renderer\ViewRenderer;

/**
 * Implements hook_views_data_alter().
 */
function entity_print_views_data_alter(array &$data) {
  foreach (\Drupal::entityTypeManager()
    ->getDefinitions() as $entity_type_id => $entity_type) {
    if (isset($data[$entity_type_id])) {
      $data[$entity_type_id]['entity_print_' . $entity_type_id] = [
        'field' => [
          'title' => t('Print link'),
          'help' => t('Provide a link to print the entity'),
          'id' => 'entity_print_views_link',
        ],
      ];
    }
  }
}

/**
 * Implements hook_entity_type_alter().
 */
function entity_print_views_entity_type_alter(array &$entity_types) {
  $entity_types['view']
    ->setHandlerClass('entity_print', ViewRenderer::class);
}