Feature #90374

Add setOriginaFile / setFile setter to TYPO3\CMS\Extbase\Domain\Model\FileReference

Added by This Mächler over 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Start date:
2020-02-15
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
FAL FileReference Extbase Create setOriginalResource
Complexity:
no-brainer
Sprint Focus:

Description

Creating a new file reference in frontend context is not properly possible right now.

I read this tutorial that describes the issue:
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Fal/UsingFal/ExamplesFileFolder.html?highlight=file%20reference#in-the-frontend-context

And studied this example:
"A cleaner solution using Extbase requires far more work. An example can be found here: https://github.com/helhum/upload_example"

The problem is, that this approach is not clean. resourceFactory->createFileReferenceObject creates a dead useless sys_file_reference - record in the database (with just a relation to the file, but not to any foreign table record) each time a new file-reference is created. This is only necessary to provide a 'originalResource' to the TYPO3\CMS\Extbase\Domain\Model\FileReference, which does noting else than fetching the original file from the useless ghos-file-reference:

   public function setOriginalResource(\TYPO3\CMS\Core\Resource\ResourceInterface $originalResource)
     {
         $this->originalResource = $originalResource;
         $this->uidLocal = (int)$originalResource->getOriginalFile()->getUid();
     }

This could be avoided by just adding a public function to set the file directly to the reference (which makes a lot of sense?):

   public function setOriginalFile(\TYPO3\CMS\Core\Resource\File $originalFile)
     {
         $this->uidLocal = (int)$originalFile->getUid();
     }

Just now you have to create your own class derived from TYPO3\CMS\Extbase\Domain\Model\FileReference and add this setter to avoid creating a dead record.

Second problem comes on persisting the file reference by the exbase framework, the created record does have an empty 'table_local' field, which leads to improper handling of the reference in the backend, see here: https://forge.typo3.org/issues/90373

Would be nice to have this fixed, making FAL work properly with extbase!


Related issues

Related to TYPO3 Core - Feature #88833: Extend possibility to create FileReference in frontend with a given File objectNew2019-07-24

Actions
Related to TYPO3 Core - Bug #66813: Persisting extbase FileReference does not work with default TCA configurationAccepted2015-05-06

Actions
Related to TYPO3 Core - Bug #90373: Persisting FileReference in Extbase leads to empty 'table_local' field in sys_file_referenceNew2020-02-15

Actions
Related to TYPO3 Core - Bug #48965: FileReference can't be created in Frontend contextClosed2013-06-08

Actions
Related to TYPO3 Core - Bug #78044: Can't create \TYPO3\CMS\Extbase\Domain\Model\FileReference from \TYPO3\CMS\Core\Resource\File nor from \TYPO3\CMS\Extbase\Domain\Model\FileNew2016-09-22

Actions
#1

Updated by Christian Eßl over 1 year ago

  • Related to Feature #88833: Extend possibility to create FileReference in frontend with a given File object added
#2

Updated by Christian Eßl over 1 year ago

  • Related to Bug #66813: Persisting extbase FileReference does not work with default TCA configuration added
#3

Updated by Christian Eßl over 1 year ago

  • Related to Bug #90373: Persisting FileReference in Extbase leads to empty 'table_local' field in sys_file_reference added
#4

Updated by Christian Eßl over 1 year ago

  • Related to Bug #48965: FileReference can't be created in Frontend context added
#5

Updated by Christian Eßl over 1 year ago

  • Related to Bug #78044: Can't create \TYPO3\CMS\Extbase\Domain\Model\FileReference from \TYPO3\CMS\Core\Resource\File nor from \TYPO3\CMS\Extbase\Domain\Model\File added

Also available in: Atom PDF