You are here

swagger_ui_formatter.install in Swagger UI Field Formatter 7.2

Same filename and directory in other branches
  1. 8.3 swagger_ui_formatter.install
  2. 8.2 swagger_ui_formatter.install

Install, update and uninstall functions for the Swagger UI Formatter module.

File

swagger_ui_formatter.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Swagger UI Formatter module.
 */

/**
 * Implements hook_requirements().
 */
function swagger_ui_formatter_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();
  if ($phase == 'runtime') {
    $library = libraries_load('swagger_ui');
    if (!$library['loaded']) {
      $requirements_value = $t('Error loading Swagger UI library! @error', array(
        '@error' => $library['error message'],
      ));
      $requirements_severity = REQUIREMENT_ERROR;
    }
    else {
      $requirements_value = $t('Correct Swagger UI Formatter configuration.');
      $requirements_severity = REQUIREMENT_OK;
    }
    $requirements['swagger_ui_configuration_check'] = array(
      'title' => $t('Swagger UI Formatter configuration'),
      'value' => $requirements_value,
      'severity' => $requirements_severity,
    );
  }
  return $requirements;
}

Functions