function _adobe_edge_fonts_get_fonts_from_api in @font-your-face 8.3
Retrieves fonts from api and parses them for consumption.
Return value
array|bool List of fonts ready for ingesting as FontInterface objects.
1 call to _adobe_edge_fonts_get_fonts_from_api()
- adobe_edge_fonts_fontyourface_import in modules/
adobe_edge_fonts/ adobe_edge_fonts.module - Implements hook_fontyourface_import().
File
- modules/
adobe_edge_fonts/ adobe_edge_fonts.module, line 111 - Adobe Edge Fonts module file.
Code
function _adobe_edge_fonts_get_fonts_from_api() {
try {
$uri = 'https://edgewebfonts.adobe.com/data/fontData.json';
$response = \Drupal::httpClient()
->get($uri, [
'headers' => [
'Accept' => 'text/plain',
],
'verify' => FALSE,
]);
$data = (string) $response
->getBody();
} catch (RequestException $e) {
Drupal::messenger()
->addMessage(t('The list of Adobe Edge Fonts could not be fetched. Verify that your server can connect the Adobe Edge Servers (https://edgewebfonts.adobe.com). Error: %error', [
'%error' => $e->error,
]), 'error');
return FALSE;
}
$json_fonts_results = json_decode($data);
return _adobe_edge_fonts_convert_api_results($json_fonts_results->families);
}