You are here

function views_pdf_requirements in Views PDF 8

Same name and namespace in other branches
  1. 6 views_pdf.install \views_pdf_requirements()
  2. 7.3 views_pdf.install \views_pdf_requirements()
  3. 7 views_pdf.install \views_pdf_requirements()
  4. 7.2 views_pdf.install \views_pdf_requirements()

Implements hook_requirements().

File

./views_pdf.install, line 12
Install the views module

Code

function views_pdf_requirements($phase) {
  $requirements = [];
  if ($phase !== 'runtime') {
    return $requirements;
  }
  if (class_exists(\TCPDF::class)) {
    $requirements['views_pdf_fpdi_tcpdf'] = [
      'title' => t('Views pdf: TCPDF library'),
      'severity' => REQUIREMENT_OK,
      'value' => t('TCPDF correctly installed.'),
    ];
  }
  else {
    $requirements['views_pdf_fpdi_tcpdf'] = [
      'title' => t('Views pdf: TCPDF library'),
      'severity' => REQUIREMENT_ERROR,
      'value' => t('TCPDF is missing.'),
    ];
  }
  if (class_exists(Fpdi::class)) {
    $requirements['views_pdf_fpdi'] = [
      'title' => t('Views pdf: FPDI library'),
      'severity' => REQUIREMENT_OK,
      'value' => t('FPDI correctly installed. Current version :version', [
        ':version',
        Fpdi::VERSION,
      ]),
    ];
  }
  else {
    $requirements['views_pdf_fpdi'] = [
      'title' => t('Views pdf: FPDI library'),
      'severity' => REQUIREMENT_OK,
      'value' => t('FPDI is missing'),
    ];
  }
  return $requirements;
}