Provide a trait to create file upload validators from file field settings

Created on 25 September 2023, about 1 year ago
Updated 4 March 2024, 9 months ago

Problem/Motivation

As part of 📌 [META] Modernise file upload logic Active we are removing duplicated logic in the different ways files can be uploaded.

The following classes define a way to get file upload validators from settings using (almost) identical logic.

  • \Drupal\file\Plugin\Field\FieldType\FileItem::getUploadValidators()
  • \Drupal\file\Plugin\rest\resource\FileUploadResource::getUploadValidators()
  • \Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader::getUploadValidators()
  • and in contrib \Drupal\graphql\GraphQL\Utility\FileUpload::getUploadValidators()

Note: we can't use inheritance as there are different ways files can be uploaded (i.e. form vs input stream).

Steps to reproduce

Proposed resolution

Provide a trait that these classes can use to get file upload validators from settings.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

11.0 🔥

Component
File module 

Last updated 2 days ago

Created by

🇦🇺Australia kim.pepper 🏄‍♂️🇦🇺Sydney, Australia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024