From e4f1b2055c77611b086c3beeea124f5f91356ad7 Mon Sep 17 00:00:00 2001 From: Adam Vessey <adam@discoverygarden.ca> Date: Tue, 16 Aug 2022 14:06:04 -0300 Subject: [PATCH] It is not necessary to explicitly mark the files as permanent. --- .../AbstractBatchProcessor.php | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/src/Form/AddChildrenWizard/AbstractBatchProcessor.php b/src/Form/AddChildrenWizard/AbstractBatchProcessor.php index f5b63500..6ea426e3 100644 --- a/src/Form/AddChildrenWizard/AbstractBatchProcessor.php +++ b/src/Form/AddChildrenWizard/AbstractBatchProcessor.php @@ -75,7 +75,6 @@ abstract class AbstractBatchProcessor { $transaction = $this->database->startTransaction(); try { - $entities[] = $this->persistFile($info, $values); $entities[] = $node = $this->getNode($info, $values); $entities[] = $this->createMedia($node, $info, $values); @@ -111,30 +110,6 @@ abstract class AbstractBatchProcessor { return $this->entityTypeManager->getStorage('file')->load($info['target_id']); } - /** - * Loads and marks the target file as permanent. - * - * @param array $info - * An associative array containing at least: - * - target_id: The id of the file to load. - * - * @return \Drupal\file\FileInterface - * The loaded file, after it has been marked as permanent. - * - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException - * @throws \Drupal\Core\Entity\EntityStorageException - */ - protected function persistFile(array $info) : FileInterface { - $file = $this->getFile($info); - $file->setPermanent(); - if ($file->save() !== SAVED_UPDATED) { - throw new \Exception("Failed to update file '{$file->id()}' to be permanent."); - } - - return $file; - } - /** * Get the node to which to attach our media. *