You are here

protected function HttpServiceApiHandler::validateServiceApiDefinition in HTTP Client Manager 8

Same name and namespace in other branches
  1. 8.2 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.

Return value

bool Whether or not the api is valid.

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 223

Class

HttpServiceApiHandler
Class HttpServiceApiHandler.

Namespace

Drupal\http_client_manager

Code

protected function validateServiceApiDefinition($id, array $serviceApi) {
  $required = [
    'title',
    'base_url',
    'api_path',
  ];
  foreach ($required as $property) {
    if (!isset($serviceApi[$property])) {
      $message = sprintf('Missing required parameter "%s" in "%s" service api definition', $property, $id);
      throw new \RuntimeException($message);
    }
  }
}