You are here

public function MockHttpClientFactory::__construct in Apigee Edge 8

Constructs a new ClientFactory instance.

Parameters

\GuzzleHttp\HandlerStack $stack: The handler stack.

\Apigee\MockClient\GuzzleHttp\MockHandler $mock_stack: The mock handler stack (Allows us to queue responses).

\Drupal\Core\State\StateInterface $state: Drupal state service, used to determine whether tests should be run using the mock handler or against a remote edge instance.

Overrides ClientFactory::__construct

File

tests/modules/apigee_mock_api_client/src/MockHttpClientFactory.php, line 65

Class

MockHttpClientFactory
Class MockHttpClientFactory.

Namespace

Drupal\apigee_mock_api_client

Code

public function __construct(HandlerStack $stack, MockHandler $mock_stack, StateInterface $state) {
  $this->stack = $stack;
  $this->mock_stack = $mock_stack;

  // Check for the integration enabled environment variable.
  if ($enabled = getenv('APIGEE_INTEGRATION_ENABLE')) {
    $this->integration_enabled = !empty($enabled);

    // Callbacks won't have access to the same environment variables so save
    // the flag to state.
    $state
      ->set('APIGEE_INTEGRATION_ENABLE', $enabled);
  }
  else {
    $this->integration_enabled = !empty($state
      ->get('APIGEE_INTEGRATION_ENABLE', FALSE));
  }
  parent::__construct($stack);
}