Browse Source

It is not necessary to explicitly mark the files as permanent.

pull/896/head
Adam Vessey 3 years ago
parent
commit
e4f1b2055c
No known key found for this signature in database
GPG Key ID: 89B39535BF6D0D39
  1. 25
      src/Form/AddChildrenWizard/AbstractBatchProcessor.php

25
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.
*

Loading…
Cancel
Save