You are here

class WebformTestHandlerRemotePostClientFactory in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/modules/webform_test_handler_remote_post/src/WebformTestHandlerRemotePostClientFactory.php \Drupal\webform_test_handler_remote_post\WebformTestHandlerRemotePostClientFactory

Extend Drupal client so that we can override Guzzel client.

Hierarchy

Expanded class hierarchy of WebformTestHandlerRemotePostClientFactory

See also

\Drupal\Core\Http\ClientFactory::fromOptions

File

tests/modules/webform_test_handler_remote_post/src/WebformTestHandlerRemotePostClientFactory.php, line 14

Namespace

Drupal\webform_test_handler_remote_post
View source
class WebformTestHandlerRemotePostClientFactory extends ClientFactory {

  /**
   * {@inheritdoc}
   */
  public function fromOptions(array $config = []) {
    $default_config = [
      'verify' => TRUE,
      'timeout' => 30,
      'headers' => [
        'User-Agent' => 'Drupal/' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . \GuzzleHttp\default_user_agent(),
      ],
      'handler' => $this->stack,
      'proxy' => [
        'http' => NULL,
        'https' => NULL,
        'no' => [],
      ],
    ];
    $config = NestedArray::mergeDeep($default_config, Settings::get('http_client_config', []), $config);
    return new WebformTestHandlerRemotePostClient($config);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ClientFactory::$stack protected property The handler stack.
ClientFactory::__construct public function Constructs a new ClientFactory instance.
WebformTestHandlerRemotePostClientFactory::fromOptions public function Constructs a new client object from some configuration. Overrides ClientFactory::fromOptions