You are here

protected function HttpServiceApiHandler::validateServiceApiDefinition in HTTP Client Manager 8.2

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

Validates Service api definition.

Parameters

string $id: The service api id.

array $serviceApi: An array of service api definition.

Throws

\RuntimeException In case of invalid HTTP Service API definition.

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

File

src/HttpServiceApiHandler.php, line 275

Class

HttpServiceApiHandler
Class HttpServiceApiHandler.

Namespace

Drupal\http_client_manager

Code

protected function validateServiceApiDefinition($id, array $serviceApi) {
  foreach (self::getOverridableProperties() as $property => $isRequired) {
    if ($isRequired && !isset($serviceApi[$property])) {
      $message = sprintf('Missing required parameter "%s" in "%s" service api definition', $property, $id);
      throw new \RuntimeException($message);
    }
  }
  if (!empty($serviceApi['commands']['blacklist']) && !empty($serviceApi['commands']['whitelist'])) {
    $message = sprintf('You cannot specify both "blacklist" and "whitelist" parameters in "%s" service api definition', $id);
    throw new \RuntimeException($message);
  }
}