You are here

function entity_print_requirements in Entity Print 8

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

Implements hook_requirements().

File

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

Code

function entity_print_requirements($phase) {
  $requirements = [];
  if ($phase !== 'runtime') {
    return $requirements;
  }
  $definitions = \Drupal::service('plugin.manager.entity_print.pdf_engine')
    ->getDefinitions();
  $has_one_engine = FALSE;
  foreach ($definitions as $definition) {

    /** @var \Drupal\entity_print\Plugin\PdfEngineInterface $class */
    $class = $definition['class'];
    if ($class::dependenciesAvailable()) {
      $has_one_engine = TRUE;
    }
  }
  if (!$has_one_engine) {
    $requirements['entity_print_pdf_engine_available'] = [
      'title' => t('PDF Engine available'),
      'description' => t('At least one valid PDF engine must be available to use Entity Print. See the <a href=":docs">documentation</a>', [
        ':docs' => 'https://www.drupal.org/node/2706755',
      ]),
      'severity' => REQUIREMENT_ERROR,
    ];
  }
  return $requirements;
}