Browse Source

manually implementing postsave (#815)

* manually implementing postsave

* it was the see
pull/817/head
Daniel Aitken 4 years ago committed by GitHub
parent
commit
e57b9e709a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      composer.json
  2. 1
      islandora.info.yml
  3. 22
      islandora.module

1
composer.json

@ -29,7 +29,6 @@
"drupal/token" : "^1.3",
"drupal/flysystem" : "^1.0",
"islandora/crayfish-commons": "dev-dev",
"drupal/hook_post_action" : "^1.0",
"drupal/file_replace": "^1.1"
},

1
islandora.info.yml

@ -31,5 +31,4 @@ dependencies:
- content_translation
- flysystem
- token
- hook_post_action
- file_replace

22
islandora.module

@ -120,6 +120,8 @@ function islandora_media_insert(MediaInterface $media) {
$media
);
}
// Wait until the media insert is complete, then fire file derivatives.
drupal_register_shutdown_function('_islandora_fire_media_file_derivative_reaction', $media);
}
/**
@ -170,18 +172,24 @@ function islandora_media_delete(MediaInterface $media) {
}
/**
* Implements hook_ENTITYTYPE_postsave().
* Helper to fire media derivative file reactions after a media 'insert'.
*
* This function should not be called on its own; it exists as a workaround to
* being unable to fire media events after a media insert operation. This
* behaviour will eventually be replaced by event listeners once these are
* implemented in Drupal 9.
*
* @param \Drupal\Core\Media\MediaInterface $media
* The media that was just inserted.
*
* @see https://www.drupal.org/project/drupal/issues/2551893
*/
function islandora_media_postsave(EntityInterface $media, $op) {
function _islandora_fire_media_file_derivative_reaction(MediaInterface $media) {
$utils = \Drupal::service('islandora.utils');
// Add derived file to the media.
if ($op == 'insert') {
// Execute derivative file reactions.
$utils->executeMediaReactions('\Drupal\islandora\Plugin\ContextReaction\DerivativeFileReaction', $media);
}
}
/**
* Implements hook_file_insert().
*/

Loading…
Cancel
Save