You are here

public function AkamaiClientBase::__construct in Akamai 8.3

AkamaiClient constructor.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

array $plugin_definition: The plugin implementation definition.

\Akamai\Open\EdgeGrid\Client $client: Akamai EdgeGrid client.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory.

\Psr\Log\LoggerInterface $logger: A logger instance.

\Drupal\Core\Messenger\MessengerInterface $messenger: A messenger service.

\Drupal\akamai\KeyProviderInterface $key_provider: A key provider service.

Overrides PluginBase::__construct

File

src/AkamaiClientBase.php, line 114

Class

AkamaiClientBase
Connects to the Akamai EdgeGrid.

Namespace

Drupal\akamai

Code

public function __construct(array $configuration, $plugin_id, array $plugin_definition, EdgeGridClient $client, ConfigFactoryInterface $config_factory, LoggerInterface $logger, MessengerInterface $messenger, KeyProviderInterface $key_provider) {
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  $this->logger = $logger;
  $this->configFactory = $config_factory;
  $this->client = $client;
  $this
    ->setAction(key(array_filter($this->configFactory
    ->get('akamai.settings')
    ->get("action_{$plugin_id}"))))
    ->setDomain(key(array_filter($this->configFactory
    ->get('akamai.settings')
    ->get('domain'))))
    ->setBaseUrl($this->configFactory
    ->get('akamai.settings')
    ->get('basepath'))
    ->setLogRequests($this->configFactory
    ->get('akamai.settings')
    ->get('log_requests'));

  // Create an authentication object so we can sign requests.
  $auth = AkamaiAuthentication::create($config_factory, $messenger, $key_provider);
  $this->akamaiClientConfig = $this
    ->createClientConfig($auth);
  if ($this->logRequests) {
    $this
      ->enableRequestLogging();
  }
  $this->client
    ->__construct($this->akamaiClientConfig, $auth);
}