You are here

function entity_print_install in Entity Print 8

Same name and namespace in other branches
  1. 8.2 entity_print.install \entity_print_install()

Implements hook_install().

1 call to entity_print_install()
EntityPrintAdminTest::testViewPdfLink in src/Tests/EntityPrintAdminTest.php
Test the view PDF extra field and the configurable text.

File

./entity_print.install, line 11
Entity Print installation file.

Code

function entity_print_install() {
  $entity_type_manager = \Drupal::entityTypeManager();
  $storage = $entity_type_manager
    ->getStorage('entity_view_mode');

  // Add a PDF view mode if the node entity type exists and the PDF view mode
  // does not already exist.
  if ($entity_type_manager
    ->getDefinition('node', FALSE) && !$storage
    ->load('node.pdf')) {
    $storage
      ->create(array(
      'targetEntityType' => 'node',
      'id' => 'node.pdf',
      'status' => TRUE,
      'label' => t('PDF'),
    ))
      ->save();
  }
}