From f2183d21de66299272a3f3552934dd5fafe20d96 Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 23 May 2017 12:23:51 +0200 Subject: [PATCH] initial --- audiofix_ror.info.yml | 8 ++++++++ audiofix_ror.module | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 audiofix_ror.info.yml create mode 100644 audiofix_ror.module diff --git a/audiofix_ror.info.yml b/audiofix_ror.info.yml new file mode 100644 index 0000000..e53812d --- /dev/null +++ b/audiofix_ror.info.yml @@ -0,0 +1,8 @@ +name: Audio fix ROR +type: module +description: 'FIX Archive.org links; add duration' +core: 8.x +version: 0.1 +package: Ondarossa +dependencies: + - paragraphs diff --git a/audiofix_ror.module b/audiofix_ror.module new file mode 100644 index 0000000..f5c6c0b --- /dev/null +++ b/audiofix_ror.module @@ -0,0 +1,45 @@ +bundle() !== 'audio') { // audio e' il nome del nostro paragraph type + return; + } + // campi utili: field_audio_link e field_durata + $link = $entity->get('field_audio_link')->getValue(); + if(count($link) == 0) { return; } + $link = $link[0]['uri']; + if(is_string($link) && isArchive($link)) { + $norm = normalizeArchive($link); + if($norm !== $link) { + \Drupal::logger('audiofix_ror')->notice('Aggiornato da :old a :new', array(":old" => $link, ":new" => $norm)); + $entity->set('field_audio_link', $norm); + } + } +}