Create a new FileRepository for the code from Drupal\file\FileStorage

Created on 23 October 2023, about 1 year ago

Problem/Motivation

The database driver for MongoDB needs to override the class Drupal\Core\Entity\Sql\SqlContentEntityStorage. MongoDB does document/JSON storage instead of relational database storage.
The File entity is overriding that class in Drupal\file\FileStorage. The problem for the database driver for MongoDB is that it then also needs to override the methods in Drupal\file\FileStorage. It also needs to duplicate the code inside Drupal\file\FileStorage too. Duplicating code is wrong.
Another problem is that the code in Drupal\file\FileStorage class is that it is NOT extending the functionality from the class Drupal\Core\Entity\Sql\SqlContentEntityStorage. The extra code can easily being moved to another class.

Proposed resolution

- Create a new Drupal\file\FileRepository class/service and move the code/methods from Drupal\file\FileStorage to the new class/service.
- Deprecate the methods and the class Drupal\file\FileStorage.

Remaining tasks

User interface changes

None

API changes

- New service file_repository with the method spaceUsed().
- The method Drupal\file\FileStorage::spaceUsed() is deprecated.
- The class Drupal\file\FileStorage is deprecated.

Data model changes

None

Release notes snippet

None

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
File systemΒ  β†’

Last updated 2 days ago

Created by

πŸ‡³πŸ‡±Netherlands daffie

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

Comments & Activities

  • Issue created by @daffie
  • πŸ‡³πŸ‡±Netherlands daffie

    Fixed typo

  • πŸ‡¦πŸ‡ΊAustralia kim.pepper πŸ„β€β™‚οΈπŸ‡¦πŸ‡ΊSydney, Australia

    We already have a Drupal\file\FileRepository class/service which is much more about manipulating file entities. e.g.

    • writeData(string $data, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface;
    • copy(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface;
    • move(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface;
    • loadByUri(string $uri): ?FileInterface;

    Not sure if it is the right place to add public function spaceUsed() there.

Production build 0.71.5 2024