Project

General

Profile

Actions

Feature #90374

closed

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

Added by This Mächler almost 5 years ago. Updated 4 months ago.

Status:
Closed
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 5 (2 open3 closed)

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

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

Actions
Related to TYPO3 Core - Bug #90373: Persisting FileReference in Extbase leads to empty 'table_local' field in sys_file_referenceClosed2020-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\FileClosed2016-09-22

Actions
Actions

Also available in: Atom PDF