You are here

function new_relic_rpm_drush_init in New Relic 8

Same name and namespace in other branches
  1. 7 new_relic_rpm.drush.inc \new_relic_rpm_drush_init()

Implements hook_drush_init().

File

./new_relic_rpm.drush.inc, line 11
New Relic Drush integration.

Code

function new_relic_rpm_drush_init() {
  if (\Drupal::hasService('new_relic_rpm.adapter')) {

    /** @var \Drupal\new_relic_rpm\ExtensionAdapter\NewRelicAdapterInterface $adapter */
    $adapter = \Drupal::service('new_relic_rpm.adapter');

    // Add custom parameter, telling the drush command executed.
    $command = drush_get_command();
    $drush_command = array_merge([
      $command['command'],
    ], $command['arguments']);
    $adapter
      ->addCustomParameter('Drush command', implode(' ', $drush_command));

    // Set job state.
    $adapter
      ->setTransactionState(\Drupal::config('new_relic_rpm.settings')
      ->get('track_drush'));
  }
}