You are here

public function Api::__construct in Fastly 8.3

Constructs a \Drupal\fastly\Api object.

Parameters

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

string $host: The host to use to talk to the Fastly API.

\GuzzleHttp\ClientInterface $http_client: The HTTP client.

\Psr\Log\LoggerInterface $logger: The Fastly logger channel.

\Drupal\fastly\State $state: The Fastly state service.

string $connectTimeout: The timeout for connections to the Fastly API.

\Drupal\fastly\Services\Webhook $webhook: The Fastly webhook service.

\Symfony\Component\HttpFoundation\RequestStack $requestStack: The request stack object.

\Drupal\fastly\CacheTagsHash $cache_tags_hash: CacheTagsHash service.

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

File

src/Api.php, line 124

Class

Api
Fastly API for Drupal.

Namespace

Drupal\fastly

Code

public function __construct(ConfigFactoryInterface $config_factory, $host, ClientInterface $http_client, LoggerInterface $logger, State $state, $connectTimeout, Webhook $webhook, RequestStack $requestStack, CacheTagsHash $cache_tags_hash, Messenger $messenger) {
  $config = $config_factory
    ->get('fastly.settings');
  $this->apiKey = getenv('FASTLY_API_TOKEN') ?: $config
    ->get('api_key');
  $this->serviceId = getenv('FASTLY_API_SERVICE') ?: $config
    ->get('service_id');
  $this->purgeMethod = $config
    ->get('purge_method') ?: PurgeOptionsForm::FASTLY_INSTANT_PURGE;
  $this->purgeLogging = $config
    ->get('purge_logging');
  $this->connectTimeout = $connectTimeout;
  $this->host = $host;
  $this->httpClient = $http_client;
  $this->logger = $logger;
  $this->state = $state;
  $this->webhook = $webhook;
  $this->baseUrl = $requestStack
    ->getCurrentRequest()
    ->getHost();
  $this->cacheTagsHash = $cache_tags_hash;
  $this->messenger = $messenger;
}