Review main Abandoned

78166[TASK] Added FileReferenceFactory to create a file reference from file

JAKOTA Design Group GmbH CR 0 V 0 Easy +48 −0 updated 03/02/26, 13:42

Commit message

Review

  • Code review CR 0
  • Verified V 0
    • core-ci +1 CI

Issues 2

Files 1

Review log 4152

Show 1927 earlier messages
  1. JAKOTA Design Group GmbH uploaded patch set 1 03/17/23, 23:40

  2. core-ci voted on patch set 1 V +1 03/17/23, 23:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39170

  3. JAKOTA Design Group GmbH marked it work in progress 03/17/23, 23:48

  4. JAKOTA Design Group GmbH updated the commit message in patch set 2 V +1 03/17/23, 23:52

  5. core-ci voted on patch set 2 V +1 03/17/23, 23:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39171

  6. Jan Kornblum uploaded patch set 3 V +1 07/14/24, 21:14

  7. Jan Kornblum updated the commit message in patch set 4 07/14/24, 21:17

  8. Jan Kornblum voted on patch set 4 CR +1 V +1 07/14/24, 21:19

  9. core-ci voted on patch set 3 V +1 07/14/24, 21:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61559

  10. core-ci voted on patch set 4 V +1 07/14/24, 21:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61560

  11. JAKOTA Design Group GmbH marked it ready for review 07/15/24, 11:30

  12. JAKOTA Design Group GmbH commented on patch set 4 07/15/24, 11:48

    Hi Jan, you removed the branch 11.5 as a release target. But if this is a bugfix all maintained version should/must be covered. In this case it should be main, 12.4, 11.5 If this is indeed a new feature the change to main is correct but title must be changed from bugfix to feature as well. And new features need a rst file.
  13. Georg Ringer updated the commit message in patch set 5 CR +1 V +1 07/15/24, 12:20

  14. Georg Ringer commented on patch set 5 07/15/24, 12:21

    11.5 is so called old stable and doesnt need to get all bugfixes - the bug has been there since ever. so I am pretty sure people have found other ways in 11.5 already
  15. Georg Ringer updated the commit message in patch set 6 07/15/24, 12:22

  16. Georg Ringer voted on patch set 6 CR +1 V +1 07/15/24, 12:22

  17. Jan Kornblum commented on patch set 6 CR +1 V +1 07/15/24, 12:26

    Reply

    Hi! Sorry about removing the branch, I am new to taking part in core contribution. I don’t know which way has a better chance to get this issue finally to core. My origin forge issue was a „feature“, but feel free to change the patch to whatever you think makes more sense. I suppose you are more experienced with the workflow ;)
  18. core-ci voted on patch set 5 V +1 07/15/24, 12:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61582

  19. core-ci voted on patch set 6 V +1 07/15/24, 12:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61583

  20. Benni Mack commented on patch set 6 07/15/24, 14:35

    FileReference.php:37

    what's wrong with setOriginalResource() ?
  21. Jan Kornblum commented on patch set 6 07/15/24, 16:01

    FileReference.php:37 Reply

    Ah, ok... But it seems that this way would require to create a \TYPO3\CMS\Core\Resource\FileReference first (instead of the extbase file reference), which is only possible using its constructor, which only accepts File object data in array notation (uid_local). Not so nice, but possible, of course... So instead of adding the 'setOriginalFile()' to extbase file reference, might adding something like 'createFromFile()' to core file reference, or extending its constructor, be any alternative? At least i will change this to "feature" here (according to my related forge issue)...
  22. Jan Kornblum updated the commit message in patch set 7 CR +1 V +1 07/15/24, 16:02

  23. core-ci voted on patch set 7 V +1 07/15/24, 16:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61595

  24. Benni Mack updated the commit message in patch set 8 V +1 10/18/24, 13:38

  25. core-ci voted on patch set 8 V -1 10/18/24, 22:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68011

  26. Benni Mack commented on patch set 8 10/31/24, 10:52

    FileReference.php:37 Reply

    please just add createFromFile(), and make it a Task, which is totally OK.
  27. JAKOTA Design Group GmbH uploaded patch set 9 V -1 03/19/25, 15:08

  1. core-ci voted on patch set 9 V +1 03/19/25, 15:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75845

  2. Garvin Hicking commented on patch set 9 CR +1 V +1 03/19/25, 15:34

    I like this; we need to cover this in the documentation. I wonder if an 'Important.rst' would be acceptable for this to both raise awareness and create a pointer for the Docs team to add this to the docs?
  3. Jan Kornblum voted on patch set 9 CR +1 03/19/25, 15:44

  4. Jan Kornblum voted on patch set 9 V +1 03/19/25, 15:44

  5. Benni Mack commented on patch set 9 03/19/25, 15:58

    Reply

    If we do this, I suggest we should quickly define if this is a) the way-to-go in Extbase with Factory Method Pattern b) we should add this to Extbase File Entity as well. c) document the Factory Method Pattern in the Core Guidelines (can be done separately of course) I do wonder - however - that for me it's unclear if this Entity now is "dirty" or if I can persist it right away, or when to use this method. I also feel like this could be quite cool when "uploading" a new file via Extbase, and then create a reference to my own actual entity (let's say "hotel-offer") and attach it there? You know, what I'm saying, we need to nail down the use-cases in an RST. And while writing, this is actually a really cool feature then (= 14.0)
  6. Garvin Hicking commented on patch set 9 CR 0 03/19/25, 16:10

    Reply Unresolved

    Good thoughts. I'd love to hear @derhansen@gmail.com 's feedback on this before I say anything unwise though. ;) The UploadedFileReferenceConverter also uses this boilerplate and could then utilize `createFileReferenceObject` in its `createFileReferenceFromFalFileObject` method probably. Being able to have this in v13 though would make the extbase file upload API a bit more well-rounded for custom FileReference juggling, so I'd tend to opt for not specifically tagging this as a feature when the code scope stays like it is now. Bigger reworks of course would require it.
  7. Benjamin Franzke commented on patch set 9 CR -1 03/19/25, 17:32

    FileReference.php:42

    Hey, this factory pattern in models is a no-go from DI perspective. We *must* not use `GeneralUtility::makeInstance` to obtain services in data(!) classes, we are never able to recover from such an API without a breaking change. (That's a general rule, `GeneralUtility::makeInstance` for service discovery must be avoided whenever possible) Factories should to be provided via separate services (that can inject dependencies via DI), that makes them extendable, replacable and in general avoids any `makeInstance` hacks.
  8. JAKOTA Design Group GmbH commented on patch set 9 03/22/25, 03:55

    FileReference.php:42 Reply

    Hey, Thanks for your review. But I'm not sure what to do here. Can you point me to an example on how to do it the right way? So I can make the necessary changes and would it be ok to change this in line 62 as well or should this be done in a separate MR?
  9. Benni Mack commented on patch set 9 CR -1 04/11/25, 15:47

    FileReference.php:42 Reply Unresolved

    Hey, instead of using the "factory method" design pattern (a.k.a. "static create...() method") we should actually use a real Factory for this. So we'd need a new class FileReferenceFactory. In this class, we inject the ResourceFactory and do our thing.
  10. Benni Mack marked it work in progress 04/11/25, 15:47

  11. Stefan Neufeind commented on patch set 9 07/07/25, 12:27

    Is the FileReferenceFactory Benni mentioned a final soltuion we could agree upon? If so, could this review maybe progressed in that direction?
  12. JAKOTA Design Group GmbH uploaded patch set 10 CR +1 V +1 07/07/25, 14:19

  13. core-ci voted on patch set 10 V +1 07/07/25, 14:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81429

  14. JAKOTA Design Group GmbH commented on patch set 10 07/07/25, 14:31

    Hi, I've worked on this a while back but then forgot about it. Thanks Stefan to for the ping here. Also while browsing the T3 code base I've found like 10 ways to implement a Factory class. So I have no idea if this is the best practice. Any input is very appreciated.
  15. Garvin Hicking marked it ready for review 07/07/25, 15:55

  16. Stefan Neufeind commented on patch set 10 V +1 07/07/25, 16:25

    (needed to adapt small parts to make it usable on an older TYPO3/PHP)
  17. Garvin Hicking commented on patch set 10 07/15/25, 14:43

    FileReferenceFactory.php:41

    The main idea of this new "API" is to unify handling (even though it could be easily added inside an extension's own scope, or part of a custom utility method now that I see it ;)) If we add this as API, I believe we should also allow to adjust the 'crop' data. And we possibly also need to allow passing future extra arguments to the createFileReferenceObject() method....?
  18. JAKOTA Design Group GmbH uploaded patch set 11 V +1 09/29/25, 20:05

  19. core-ci voted on patch set 11 V +1 09/29/25, 20:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85710

  20. JAKOTA Design Group GmbH commented on patch set 11 09/29/25, 20:25

    FileReferenceFactory.php:41 Reply

    Sorry for the late reply, but yes passing the 'crop' parameter here is a good idea. I don't know why I didn't added it in the first place. Depending on how many future extra arguments we are talking about. We could just add them as optional parameter or just hand over an array. Which I'm not a big fan of, if its typeless. But then again, the parameter $fileReferenceData in createFileReferenceObject is just an array also. So I'm fine with it either way.
  21. Garvin Hicking commented on patch set 11 09/30/25, 18:50

    FileReferenceFactory.php:41 Reply

    Thanks for adding this crop parameter. After some time has passed I'm thinking we don't need to support arbitrary data for now - adding it like you mention to the method signature for future options could be okay. If we refactor the "FileReference" option we might provide a data object for the config instead of an array anyways. Resolving this for now. I'd like to bring this up in a core dev meeting to talk about Bennis comments so we can decide on whether this public API is going to be "good". Of course, feedback here is also much appreciated.
  22. Garvin Hicking commented on patch set 11 10/10/25, 15:40

    FileReferenceFactory.php:41 Reply

    We've talked about this today in the merger channel, and specifically with @stefan@buerk.tech - he's going to create a small write-up here.
  23. Garvin Hicking commented on patch set 11 02/27/26, 09:47

    FileReferenceFactory.php:41 Reply

    I'll take this over with a short form: I think adding such a convenience short form adds a layer of maintenance that we don't necessarily want to provide in TYPO3 core. We think it is lightweight enough to put it into a project's scope. Because if such a factory is utilized, you'll very likely have FAL API code in your project already that interfaces with it, and where you could place this. Because very likely you will do additional things to your file reference then, and that would make a whole "abstract" factory a bit moot. I hope you can understand the reasoning, else I'm sure Stefan will be able to say more about it.
  24. Garvin Hicking abandoned the change 02/27/26, 09:47

    abandoned, see comment
  25. JAKOTA Design Group GmbH commented on patch set 11 03/02/26, 13:42

    FileReferenceFactory.php:41 Reply

    Acknowledged