From f73bfbb1e3b5b7da0734819995204b635e058661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Serf=C5=91z=C5=91?= Date: Mon, 21 Aug 2023 09:19:10 +0200 Subject: [PATCH] INFOPORTAL-5728 dev: Automatically delete media created in tests. --- src/Drush/Commands/PlaywrightDrushCommands.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Drush/Commands/PlaywrightDrushCommands.php b/src/Drush/Commands/PlaywrightDrushCommands.php index d2087ac..d1c5a10 100644 --- a/src/Drush/Commands/PlaywrightDrushCommands.php +++ b/src/Drush/Commands/PlaywrightDrushCommands.php @@ -270,6 +270,17 @@ public function cleanUpContent(string $keyword) { $taxonomy_term_storage->delete($terms); } } + $media_storage = $this->getEntityTypeManager()->getStorage('media'); + $mids = $media_storage->getQuery() + ->accessCheck(FALSE) + ->condition('name', $keyword, 'STARTS_WITH') + ->execute(); + if (!empty($mids)) { + $media = $media_storage->loadMultiple($mids); + if (!empty($media)) { + $media_storage->delete($media); + } + } } /**