new_relic_rpm.install in New Relic 8
Same filename and directory in other branches
Install and uninstall functions for the New Relic module.
File
new_relic_rpm.installView source
<?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);
}Functions
| 
            Name | 
                  Description | 
|---|---|
| new_relic_rpm_install | Implements hook_install(). | 
| new_relic_rpm_requirements | Implements hook_requirements(). |