X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Flibraries%2Fsrc%2FExternalLibrary%2FDefinition%2FGuzzleDefinitionDiscovery.php;fp=web%2Fmodules%2Fcontrib%2Flibraries%2Fsrc%2FExternalLibrary%2FDefinition%2FGuzzleDefinitionDiscovery.php;h=59745b78c7fbd6523287da0bce6f14ce601d7f22;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hp=0000000000000000000000000000000000000000;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35;p=yaffs-website diff --git a/web/modules/contrib/libraries/src/ExternalLibrary/Definition/GuzzleDefinitionDiscovery.php b/web/modules/contrib/libraries/src/ExternalLibrary/Definition/GuzzleDefinitionDiscovery.php new file mode 100644 index 000000000..59745b78c --- /dev/null +++ b/web/modules/contrib/libraries/src/ExternalLibrary/Definition/GuzzleDefinitionDiscovery.php @@ -0,0 +1,71 @@ +httpClient = $http_client; + } + + /** + * {@inheritdoc} + */ + public function hasDefinition($id) { + try { + $response = $this->httpClient->request('GET', $this->getFileUri($id)); + return $response->getStatusCode() === 200; + } + catch (GuzzleException $exception) { + return FALSE; + } + } + + /** + * {@inheritdoc} + */ + 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); + } + } + +}