Review main Merged

85925[TASK] Extend RecordInterface

Oli Bartsch CR +2 V +2 Hard +450 −292 updated 09/11/24, 11:49

Commit message

The RecordInterface is extended to require
implementations to implement the `getRawRecord()`
and `getSystemProperties()` methods as well
as the PSR-11 `ContainerInterface`.

This allows to change RecordFactory's `createRecord()`
method to return the interface instead of the
`Record` object. This will come in handy e.g.
for the already existing `Page` object, which
can now be used without extending `Record`.

By using the `ContainerInterface` we allow
access to the record and its properties via
the has() and get() methods, which is supported
since Fluid 4.0: https://github.com/TYPO3/Fluid/issues/1001.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Benjamin Franzke +1
    • Benni Mack +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Benjamin Franzke +1
    • Benni Mack +1

Issues 1

Files 16

Review log 2637

Show 812 earlier messages
  1. Oli Bartsch uploaded patch set 1 09/09/24, 10:23

  2. core-ci voted on patch set 1 V -1 09/09/24, 10:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65082

  3. Oli Bartsch uploaded patch set 2 V -1 09/09/24, 13:12

  4. Benjamin Franzke commented on patch set 2 CR -1 09/09/24, 13:18

    RecordInterface.php:25

    `ArrayAccess` is a bit unfortunate as we don't really want `offsetUnset` and `offsetSet`… It would be awesome to just support something like `Psr\Container\ContainerInterface` in fluid for property resolution, so you'd actually only need `has()` and `get()`. In case that needs time (fluid release), we should at least move
  5. core-ci voted on patch set 2 V -1 09/09/24, 13:19 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65094

  6. Oli Bartsch uploaded patch set 3 CR -1 V -1 09/09/24, 13:31

  7. core-ci voted on patch set 3 V +1 09/09/24, 13:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65096

  8. Benjamin Franzke commented on patch set 3 09/09/24, 13:38

    RecordInterface.php:25 Reply

    …move it into the implementation only until fluid is adapted.
  9. Benjamin Franzke voted on patch set 3 CR -1 09/09/24, 13:40

  10. Oli Bartsch uploaded patch set 4 CR -1 V +1 09/09/24, 16:22

  11. core-ci voted on patch set 4 V +1 09/09/24, 16:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65116

  12. Stefan Bürk commented on patch set 4 09/09/24, 17:28

    RecordInterface.php:25 Reply

    @ben@bnf.dev don't get your statement here, maybe I miss some big picture here. `Psr\Container\ContainerInterface` is ment for dependency injection container and not for array-like access on objects which \ArrayAccess ensures: ``` $object = new RecordInterface(...); // new Record() / new RawRecord() $uid = $object['uid']; ``` Am I wrong here ? Beside that, don't get the connection to fluid here.
  1. Oli Bartsch updated the commit message in patch set 5 V +1 09/09/24, 18:22

  2. core-ci voted on patch set 5 V +1 09/09/24, 18:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65131

  3. Benjamin Franzke commented on patch set 5 09/10/24, 07:41

    RecordInterface.php:25 Reply

    Yes, i know it feels like an abuse of the ContainerInterface in the first place and I'm not sure how to explain my thoughts, but let me start this way: There are two patterns for ContainerInterface: * Dependency Injection * Service Location Dependency Injection is the process of automatically loading a dependency because you know it statically upfront. Service location is kind of lazy registration of certain/one service from a set of available service/object recipes. Service location is for example used in route or middleware dispatchers (services that inject ContainerInterface or symfony ServiceLocator (which itself implements ContainerInterface)). Now, our record objects, that are passed into the frontend templates are basically service location objects, as they allow to lazily load dependnecies (e.g. tt_content.image) from the record (=container). And the semantics are really quite identical, because a record is also meant to provide properties and relations as singletons (cache them, instead of recreation). So I came to the conclusion: The new automagic relation resolver is basically some kind of dependency injection (or better lazy dependency location), and therefore `ContainerInterface` became a logical and fitting choice. I understand that this feels like an abuse, but conceptionally I'm pretty sure we're basically applying the dependency injection pattern to content elements here. Now,
  4. Stefan Bürk commented on patch set 5 09/10/24, 17:42

    RecordInterface.php:25 Reply

    Thanks Benjamin to take the affort to explain the thoughts behind this. I know the ServiceLocator pattern (ZendFramework/Laminas etc ...) in general, and following your argumentation it make sense.
  5. Oli Bartsch commented on patch set 5 09/10/24, 19:18

    RecordInterface.php:25 Reply

    Done
  6. Benni Mack voted on patch set 5 CR +1 09/10/24, 19:21

  7. Oli Bartsch rebased onto patch set 6 CR +1 V +1 09/10/24, 19:21

  8. core-ci voted on patch set 6 V +1 09/10/24, 19:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65322

  9. Benni Mack voted on patch set 6 CR +1 V +1 09/10/24, 19:42

  10. Oli Bartsch uploaded patch set 7 CR +1 V +1 09/10/24, 20:31

  11. Oli Bartsch uploaded patch set 8 09/10/24, 20:46

  12. core-ci voted on patch set 7 V -1 09/10/24, 20:52 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65348

  13. core-ci voted on patch set 8 V -1 09/10/24, 20:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65352

  14. Benjamin Franzke commented on patch set 8 09/10/24, 21:12

    `has()` and `get()`

    FluidBasedContentPreviewRenderer.php:96

    what do you mean by `$output`, is that a concrete variable, or do you refer to some generic collected output?
  15. Oli Bartsch uploaded patch set 9 V -1 09/11/24, 09:46

  16. Oli Bartsch commented on patch set 9 09/11/24, 09:48

    Reply

    Done

    Reply

    Done

    FluidBasedContentPreviewRenderer.php:96 Reply

    Done
  17. core-ci voted on patch set 9 V -1 09/11/24, 10:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65407

  18. Oli Bartsch rebased onto patch set 10 V -1 09/11/24, 10:05

  19. core-ci voted on patch set 10 V +1 09/11/24, 10:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65412

  20. Benni Mack voted on patch set 10 CR +1 V +1 09/11/24, 11:42

  21. Benjamin Franzke updated the commit message in patch set 11 CR +1 V +1 09/11/24, 11:44

  22. Benni Mack voted on patch set 11 CR +1 V +1 09/11/24, 11:44

  23. Oli Bartsch voted on patch set 11 CR +2 V +2 09/11/24, 11:45

  24. Oli Bartsch merged patch set 12 09/11/24, 11:45

  25. core-ci voted on patch set 11 V +1 09/11/24, 11:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65425