diff --git a/islandora_fits.module b/islandora_fits.module index 0288d9e5..a7c9f724 100644 --- a/islandora_fits.module +++ b/islandora_fits.module @@ -42,61 +42,6 @@ function islandora_fits_theme($existing, $type, $theme, $path) { ]; } -/** - * Implements hook_ENTITY_TYPE_presave(). - */ -function islandora_fits_media_presave(MediaInterface $media) { - if ($media->bundle() != 'fits_technical_metadata') { - return; - } - else { - $transformer = \Drupal::getContainer()->get('islandora_fits.transformxml'); - $media->set('field_complete', TRUE); - $file_id = $media->get('field_media_file')->getValue()[0]['target_id']; - if ($file_id) { - $file = File::load($file_id); - $data = file_get_contents($file->getFileUri()); - // Adds any new fields to FITS media type. - $has_new = $transformer->checkNew($data); - if ($has_new) { - $media->set('field_complete', FALSE); - } - else { - $transformer->populateMedia($data, $media); - } - } - } - -} - -/** - * Implements hook_media_update(). - */ -function islandora_fits_media_update(MediaInterface $media) { - if ($media->bundle() != 'fits_technical_metadata') { - return; - } - if ($media->get('field_complete')->value == FALSE) { - $transformer = \Drupal::getContainer()->get('islandora_fits.transformxml'); - $file_id = $media->get('field_media_file')->getValue()[0]['target_id']; - $file = File::load($file_id); - $data = file_get_contents($file->getFileUri()); - $transformer->addMediaFields($data); - $new_media = Media::load($media->id()); - $new_media->set('field_complete', TRUE); - $new_media->save(); - } -} - -/** - * Implements hook_media_insert(). - */ -function islandora_fits_media_insert(MediaInterface $media) { - if ($media->bundle() == 'fits_technical_metadata') { - islandora_fits_media_update($media); - } -} - /** * Implements hook_entity_extra_field_info(). */