From 310481be343d4a7ae08921a1301efe9cf8a07c34 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Thu, 18 Jul 2019 23:53:47 -0300 Subject: [PATCH] Remove duplicate media delete action (#153) * Removing duplicate delete media action * Torching test * Update hook * Coding standards --- config/install/system.action.delete_media.yml | 13 ------- config/schema/islandora.schema.yml | 4 --- islandora.install | 12 +++++++ src/Plugin/Action/DeleteMedia.php | 35 ------------------- tests/src/Functional/DeleteMediaTest.php | 25 ------------- 5 files changed, 12 insertions(+), 77 deletions(-) delete mode 100644 config/install/system.action.delete_media.yml delete mode 100644 src/Plugin/Action/DeleteMedia.php diff --git a/config/install/system.action.delete_media.yml b/config/install/system.action.delete_media.yml deleted file mode 100644 index c95e8423..00000000 --- a/config/install/system.action.delete_media.yml +++ /dev/null @@ -1,13 +0,0 @@ -langcode: en -status: true -dependencies: - enforced: - module: - - islandora - module: - - islandora -id: delete_media -label: 'Delete media' -type: media -plugin: delete_media -configuration: { } diff --git a/config/schema/islandora.schema.yml b/config/schema/islandora.schema.yml index 7b89a25c..8fd719ce 100644 --- a/config/schema/islandora.schema.yml +++ b/config/schema/islandora.schema.yml @@ -68,10 +68,6 @@ action.configuration.emit_term_event: type: text label: 'Event Type' -action.configuration.delete_media: - type: action_configuration_default - label: 'Delete media' - action.configuration.delete_media_and_file: type: action_configuration_default label: 'Delete media and file' diff --git a/islandora.install b/islandora.install index e900f2f6..526583d4 100644 --- a/islandora.install +++ b/islandora.install @@ -40,3 +40,15 @@ function islandora_schema() { ]; return $schema; } + +/** + * Delete the 'delete_media' action we used to provide, if it exists. + * + * Use the core 'media_delete_action' instead. + */ +function islandora_update_8001(&$sandbox) { + $action = \Drupal::service('entity_type.manager')->getStorage('action')->load('delete_media'); + if ($action) { + $action->delete(); + } +} diff --git a/src/Plugin/Action/DeleteMedia.php b/src/Plugin/Action/DeleteMedia.php deleted file mode 100644 index 82c4d842..00000000 --- a/src/Plugin/Action/DeleteMedia.php +++ /dev/null @@ -1,35 +0,0 @@ -delete(); - } - } - - /** - * {@inheritdoc} - */ - public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { - return $object->access('delete', $account, $return_as_object); - } - -} diff --git a/tests/src/Functional/DeleteMediaTest.php b/tests/src/Functional/DeleteMediaTest.php index 1a3673aa..03192194 100644 --- a/tests/src/Functional/DeleteMediaTest.php +++ b/tests/src/Functional/DeleteMediaTest.php @@ -35,31 +35,6 @@ class DeleteMediaTest extends IslandoraFunctionalTestBase { list($this->file, $this->media) = $this->makeMediaAndFile($account); } - /** - * Tests the delete_media action. - * - * @covers \Drupal\islandora\Plugin\Action\DeleteMedia::execute - */ - public function testDeleteMedia() { - $action = $this->container->get('entity_type.manager')->getStorage('action')->load('delete_media'); - - $mid = $this->media->id(); - $fid = $this->file->id(); - - $action->execute([$this->media]); - - // Attempt to reload the entities. - // Media should be gone but file should remain. - $this->assertTrue( - !$this->container->get('entity_type.manager')->getStorage('media')->load($mid), - "Media must be deleted after running action" - ); - $this->assertTrue( - $this->container->get('entity_type.manager')->getStorage('file')->load($fid), - "File must remain after running action" - ); - } - /** * Tests the delete_media_and_file action. *