You are here

public function NewRelicApiClient::__construct in New Relic 8

Same name and namespace in other branches
  1. 2.x src/Client/NewRelicApiClient.php \Drupal\new_relic_rpm\Client\NewRelicApiClient::__construct()
  2. 2.0.x src/Client/NewRelicApiClient.php \Drupal\new_relic_rpm\Client\NewRelicApiClient::__construct()

Constructs a new NewRelicApiClient.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The configuration factory so we can load config that we need.

\GuzzleHttp\Client $http_client: The http client to send requests to newrelic.

\Drupal\Component\Serialization\Json $serialization_json: Decoding the returned result from newrelic.

\Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory: For logging notifications to Drupal.

\Drupal\Core\StringTranslation\TranslationInterface $string_translation: The string translation service.

File

src/Client/NewRelicApiClient.php, line 85

Class

NewRelicApiClient
Controls the interaction between us and newrelic rest API v2.

Namespace

Drupal\new_relic_rpm\Client

Code

public function __construct(ConfigFactoryInterface $config_factory, Client $http_client, Json $serialization_json, LoggerChannelFactoryInterface $logger_factory, TranslationInterface $string_translation) {
  $this->config = $config_factory
    ->get('new_relic_rpm.settings');
  $this->httpClient = $http_client;
  $this->parser = $serialization_json;
  $this->logger = $logger_factory
    ->get('new_relic_rpm');
  $this
    ->setStringTranslation($string_translation);
  $this->apiKey = $this->config
    ->get('api_key');
  $app_name = ini_get('newrelic.appname');
  if (!empty($app_name)) {
    $this
      ->setAppName($app_name);
  }
}