new_relic_rpm-8.x-1.x-dev/new_relic_rpm.install

new_relic_rpm.install
<?php

/**
 * @file
 * Install and uninstall functions for the New Relic module.
 */

use Drupal\Core\Url;

/**
 * Implements hook_requirements().
 */
function new_relic_rpm_requirements($phase) {
  $requirements = [];

  // We do not verify the extension at install time, to allow for testing when
  // it is not present.
  if ($phase == 'runtime') {
    $new_relic_loaded = extension_loaded('newrelic');
    $requirements['newrelic'] = [
      'title' => t('New Relic PHP Library'),
      'value' => $new_relic_loaded ? t('Exists') : t('Not loaded'),
      'severity' => $new_relic_loaded ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    ];
    $api_key = \Drupal::config('new_relic_rpm.settings')->get('api_key');
    $settings_url = Url::fromRoute('new_relic_rpm.settings')->toString();
    $requirements['newrelic_apikey'] = [
      'title' => t('New Relic API key'),
      'value' => ($api_key == '' ?
        t('Not set (<a href=":configure">configure</a>)', [':configure' => $settings_url]) :
        t('Available (<a href=":configure">configure</a>)', [':configure' => $settings_url])),
      'severity' => $api_key == '' ? REQUIREMENT_INFO : REQUIREMENT_OK,
    ];

  }

  return $requirements;
}

/**
 * Implements hook_install().
 */
function new_relic_rpm_install() {
  // Set New Relic RPM module's weight to very low so we can trigger job state
  // changes early. This can be important in cases like hook_cron().
  module_set_weight('new_relic_rpm', -20);
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc