Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions ding_language.module
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,49 @@ function ding_language_preprocess_eu_cookie_compliance_popup_info(&$variables) {
$variables['agree_button'] = t('OK, I agree');
}
}

/**
* Implements hook_ting_covers().
*/
function ding_language_ting_covers($entities) {
$covers = [];
$fausts = [];
foreach ($entities as $entity) {
$fausts[$entity->provider_id] = $entity->ding_entity_id;
}
try {
$service = new AdditionalInformationService(variable_get('ting_covers_addi_wsdl_url'), variable_get('ting_covers_addi_username'), variable_get('ting_covers_addi_group'), variable_get('ting_covers_addi_password'), variable_get('ting_covers_addi_enforce_url', FALSE));

// Retrieve covers by Faust.
$retrieved = $service->getByFaustNumber(array_keys($fausts));

foreach ($retrieved as $pid => $cover) {
// Try to extract the image url from the result.
$source_url = FALSE;
if ($cover->detailUrl) {
$source_url = $cover->detailUrl;
}
elseif ($cover->thumbnailUrl) {
$source_url = $cover->thumbnailUrl;
}

// If we still haven't found a cover check if we can use external URL.
if (!$source_url && isset($cover->externUrl)) {
$source_url = $cover->externUrl;
}

if ($source_url) {
// Return the path to the cover.
$covers[$fausts[$pid]] = $source_url;
}
}
}
catch (Exception $exception) {
watchdog('ding_language', 'Unable to retrieve covers from ADDI: %message', ['%message' => $exception->getMessage()], WATCHDOG_ERROR);

// Error in fetching, return no covers.
return [];
}

return $covers;
}