diff --git a/src/GraphQL/Utility/FileUpload.php b/src/GraphQL/Utility/FileUpload.php index 26ddfba0e..9367d3178 100644 --- a/src/GraphQL/Utility/FileUpload.php +++ b/src/GraphQL/Utility/FileUpload.php @@ -37,9 +37,9 @@ class FileUpload { use StringTranslationTrait; /** - * The file storage where we will create new file entities from. + * The entity storage for the 'file' entity type. * - * @var \Drupal\Core\Entity\EntityStorageInterface + * @var \Drupal\file\FileStorageInterface */ protected $fileStorage; @@ -137,7 +137,9 @@ public function __construct( ImageFactory $image_factory, FileValidatorInterface $file_validator, ) { - $this->fileStorage = $entityTypeManager->getStorage('file'); + /** @var \Drupal\file\FileStorageInterface $file_storage */ + $file_storage = $entityTypeManager->getStorage('file'); + $this->fileStorage = $file_storage; $this->currentUser = $currentUser; $this->mimeTypeGuesser = $mimeTypeGuesser; $this->fileSystem = $fileSystem; @@ -268,7 +270,7 @@ public function saveFileUpload(UploadedFile $uploaded_file, array $settings): Fi try { // Begin building file entity. - /** @var \Drupal\Core\Entity\EntityInterface $file */ + /** @var \Drupal\file\FileInterface $file */ $file = $this->fileStorage->create([]); $file->setOwnerId($this->currentUser->id()); $file->setFilename($prepared_filename); @@ -515,7 +517,7 @@ protected function prepareFilename(string $filename, array &$validators): string $passes_validation = FALSE; if (!empty($validators['FileExtension']['extensions'])) { - /** @var \Drupal\Core\Entity\EntityInterface $file */ + /** @var \Drupal\file\FileInterface $file */ $file = $this->fileStorage->create([]); $file->setFilename($filename); $passes_validation = empty($this->fileValidator->validate($file, $validators['FileExtension']['extensions'])); diff --git a/tests/modules/graphql_file_validate/graphql_file_validate.info.yml b/tests/modules/graphql_file_validate/graphql_file_validate.info.yml deleted file mode 100644 index 1443533b4..000000000 --- a/tests/modules/graphql_file_validate/graphql_file_validate.info.yml +++ /dev/null @@ -1,5 +0,0 @@ -type: module -name: GraphQL File Validate Test -description: Tests hook_file_validate() on uploads. -package: Testing -hidden: TRUE diff --git a/tests/modules/graphql_file_validate/graphql_file_validate.module b/tests/modules/graphql_file_validate/graphql_file_validate.module deleted file mode 100644 index ae89684be..000000000 --- a/tests/modules/graphql_file_validate/graphql_file_validate.module +++ /dev/null @@ -1,17 +0,0 @@ -getFileUri())) { - throw new \Exception('File does not exist during validation: ' . $file->getFileUri()); - } -} diff --git a/tests/src/Kernel/Framework/UploadFileServiceTest.php b/tests/src/Kernel/Framework/UploadFileServiceTest.php index c0307bd6b..d987991c6 100644 --- a/tests/src/Kernel/Framework/UploadFileServiceTest.php +++ b/tests/src/Kernel/Framework/UploadFileServiceTest.php @@ -15,11 +15,6 @@ */ class UploadFileServiceTest extends GraphQLTestBase { - /** - * {@inheritdoc} - */ - protected static $modules = ['file', 'graphql_file_validate']; - /** * The FileUpload object we want to test, gets prepared in setUp(). *