You are here

protected function HttpServiceApiHandler::overrideServiceApiDefinition in HTTP Client Manager 8.2

Same name and namespace in other branches
  1. 8 src/HttpServiceApiHandler.php \Drupal\http_client_manager\HttpServiceApiHandler::overrideServiceApiDefinition()

Override Service API definition.

Checks for overriding configurations for the given Service API Definition.

Parameters

string $id: The service api id.

array $serviceApi: An array of service api definition.

1 call to HttpServiceApiHandler::overrideServiceApiDefinition()
HttpServiceApiHandler::buildServicesApiYaml in src/HttpServiceApiHandler.php
Builds all services api provided by .http_services_api.yml files.

File

src/HttpServiceApiHandler.php, line 215

Class

HttpServiceApiHandler
Class HttpServiceApiHandler.

Namespace

Drupal\http_client_manager

Code

protected function overrideServiceApiDefinition($id, array &$serviceApi) {
  if (!$this->config
    ->get('enable_overriding_service_definitions')) {
    return;
  }
  $original = $serviceApi;
  $overridden = FALSE;
  $overridable_properties = self::getOverridableProperties();
  $config_overrides = $this->config
    ->get('overrides');
  if (!empty($config_overrides[$id])) {
    $settings[$id] = array_intersect_key($config_overrides[$id], $overridable_properties);
    $serviceApi = array_replace_recursive($serviceApi, $config_overrides[$id]);
    $overridden = TRUE;
  }
  $settings = Settings::get('http_services_api', []);
  if (!empty($settings[$id])) {
    $settings[$id] = array_intersect_key($settings[$id], $overridable_properties);
    $serviceApi = array_replace_recursive($serviceApi, $settings[$id]);
    $overridden = TRUE;
  }

  // Add the "orig" key only if the commands override has been specified.
  if (!empty($serviceApi['commands'])) {
    $serviceApi['orig'] = $original;
  }
  if ($overridden) {
    $serviceApi['_original'] = $original;
  }
}