You are here

protected function GuzzleDefinitionDiscovery::getSerializedDefinition in Libraries API 8.3

Gets the contents of the library file.

Parameters

$id: The library ID to retrieve the serialized definition for.

Return value

string The serialized library definition.

Throws

\Drupal\libraries\ExternalLibrary\Exception\LibraryDefinitionNotFoundException

Overrides FileDefinitionDiscoveryBase::getSerializedDefinition

File

src/ExternalLibrary/Definition/GuzzleDefinitionDiscovery.php, line 58

Class

GuzzleDefinitionDiscovery
Provides a definition discovery that fetches remote definitions using Guzzle.

Namespace

Drupal\libraries\ExternalLibrary\Definition

Code

protected function getSerializedDefinition($id) {
  try {
    $response = $this->httpClient
      ->request('GET', $this
      ->getFileUri($id));
    return (string) $response
      ->getBody();
  } catch (GuzzleException $exception) {
    throw new LibraryDefinitionNotFoundException($id, '', 0, $exception);
  } catch (\RuntimeException $exception) {
    throw new LibraryDefinitionNotFoundException($id, '', 0, $exception);
  }
}