function RestExampleClientCalls::__construct

Same name in other branches
  1. 4.0.x modules/rest_example/src/RestExampleClientCalls.php \Drupal\rest_example\RestExampleClientCalls::__construct()

The constructor.

Parameters

\GuzzleHttp\ClientInterface $client: The HTTP client.

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

File

modules/rest_example/src/RestExampleClientCalls.php, line 64

Class

RestExampleClientCalls
Here we interact with the remote service.

Namespace

Drupal\rest_example

Code

public function __construct(ClientInterface $client, ConfigFactoryInterface $config_factory) {
    $this->client = $client;
    // Retrieve the config from the configuration page set at
    // examples/rest_client_settings.
    $rest_config = $config_factory->get('rest_example.settings');
    $this->clientAuth = [
        $rest_config->get('server_password'),
        $rest_config->get('server_username'),
    ];
    $this->remoteUrl = $rest_config->get('server_url');
}