Review main Merged

76537[FEATURE] Introduce PHP attribute based backend controller registration

Bastien Lutz CR +2 V +2 Hard +151 −102 updated 11/23/22, 14:01

Commit message

Backend controller had to be registered in the extension
`Services.yaml` file with tag `backend.controller`.

This change enables automatic service registration with
the tag `backend.controller` attached to it by using the
newly introduced `\TYPO3\CMS\Backend\Attribute\Controller`
PHP attribute. Thus providing a additional and simpler
way, without deprecating or enforcing to change already
existing registrations.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Stefan Bürk +1
  • Verified V +2 Done
    • Benni Mack +2
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 38

Show 18 more files

Review log 3046

Show 1221 earlier messages
  1. Bastien Lutz uploaded patch set 1 11/10/22, 11:18

  2. core-ci voted on patch set 1 V -1 11/10/22, 11:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33459

  3. Bastien Lutz uploaded patch set 2 11/10/22, 11:30

  4. Bastien Lutz uploaded patch set 3 11/10/22, 11:31

  5. core-ci voted on patch set 2 V -1 11/10/22, 11:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33461

  6. core-ci voted on patch set 3 V -1 11/10/22, 11:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33463

  7. Bastien Lutz uploaded patch set 4 11/10/22, 12:04

  8. Bastien Lutz updated the commit message in patch set 5 11/10/22, 12:04

  9. Benjamin Franzke commented on patch set 5 11/10/22, 12:36

    Hey, thanks for the change. Tags are quite generic and I think it would be better to create distinct attribute for the respective tags (for sure, that's more work) Advantages would be * Tags Attributes would be easy to deprecate and autocomplete (IDE users will be happy about that) * The arguments for the Attributes could use proper typings and could be expressed as native attribute for the tag. That would not be possible with a generic AddTags attribute. So take a look at tags like 'console.command' which require additional settings like 'command' and 'description'
    Tags do not cause any autowiring, tags are used to register services (for usage by registries).
  10. core-ci voted on patch set 4 V -1 11/10/22, 12:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33475

  11. core-ci voted on patch set 5 V -1 11/10/22, 12:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33478

  12. Bastien Lutz uploaded patch set 6 11/10/22, 15:08

  13. Bastien Lutz updated the commit message in patch set 7 11/10/22, 15:13

  14. Oli Bartsch commented on patch set 7 11/10/22, 15:25

    Please let's have a feature RST. You can take a look at https://docs.typo3.org/m/typo3/guide-contributionworkflow/main/en-us/AddingDocumentation/Index.html#add-documentation for more information.

    AddTags.php:23

    This class is not dedicated to backend controller configuration, right?
  15. core-ci voted on patch set 6 V -1 11/10/22, 15:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33504

  16. core-ci voted on patch set 7 V -1 11/10/22, 15:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33505

  17. Bastien Lutz uploaded patch set 8 11/10/22, 15:45

  18. core-ci voted on patch set 8 V +1 11/10/22, 15:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33512

  19. Bastien Lutz uploaded patch set 9 11/10/22, 16:28

  20. core-ci voted on patch set 9 V +1 11/10/22, 16:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33519

  21. Chris Müller commented on patch set 9 11/10/22, 16:46

    Is there a reason calling the attribute "AsBackendController" and not just "BackendController"?
  1. Bastien Lutz commented on patch set 9 11/10/22, 17:35

    Reply

    Hi, ok, sounds great. To begin with i would start off with the tag 'backend.controller'. We can still add some in the future as you said.

    Reply

    Done

    Reply

    Because it should be tagged AS a BackendController. My intention was to give it a name which doesn't make a class appear unique, because this would give an impression of overwriting something. But i still wanted a name which sounds like the classes are following a pattern. And i also was inspired by the AsController PHP Attribute from Symfony. But technically there isn't any reason why it is called AsBackendController and not BackendController.

    Reply

    Done

    AddTags.php:23 Reply

    Done
  2. Benjamin Franzke commented on patch set 9 11/11/22, 09:16

    Reply

    I'd love to use: use TYPO3\CMS\Core\Attribute; #[Attribute\BackendController] class MyBackendController But that's only nice when all tags are located in EXT:core, which is probably not doable, especially when we think of extensions which will use the same paradigm for their registriert. I think the attribute needs to be provided by EXT:backend and then we can actually drop the "Backend" in the Attribute name, that is clear from the context: TYPO3\CMS\Backend\Attribute\Controller. Why not using As? Well, it's only symfony doing so, and we wouldn't do that for all Attributes, only interface-like attribute. So I'd rather use proper namespaces and to suffixes or prefixes, like the examples on https://www.php.net/manual/en/language.attributes.overview.php do. Usage could then be: use TYPO3\CMS\Backend\Attribute\Controller as ControllerAttrib; Or if you feel that's not expressive enough (for the context of the class): use TYPO3\CMS\Backend\Attribute\Controller as BackendControllerAttrib;
  3. Chris Müller uploaded patch set 10 11/11/22, 09:27

  4. core-ci voted on patch set 10 V +1 11/11/22, 09:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33556

  5. Benni Mack commented on patch set 10 11/11/22, 09:45

    Reply

    I agree with "use TYPO3\CMS\Backend\Attribute\Controller" or "use TYPO3\CMS\Backend\Attribute\ControllerAttribute"
  6. Bastien Lutz uploaded patch set 11 11/11/22, 16:41

  7. Bastien Lutz commented on patch set 11 11/11/22, 16:43

    Reply

    i ajusted the naming
  8. core-ci voted on patch set 11 V +1 11/11/22, 16:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33599

  9. Benni Mack commented on patch set 11 11/11/22, 22:32

    tbh, I like the "Controller" way better than the "use ... as BackendControllerAttrib", with an IDE it's good to use.
  10. Stefan Bürk commented on patch set 11 11/13/22, 01:05

    Feature-99055-BackendControllerServiceTagAsAttribute.rst:7

    The "=" lines must have the same length as the text in-between. Thus two "=" should be removed from L5 and L7
  11. Stefan Bürk commented on patch set 12 11/13/22, 01:05

    Published edit on patch set 11.
  12. core-ci voted on patch set 12 V +1 11/13/22, 01:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33660

  13. Stefan Bürk commented on patch set 12 11/13/22, 01:36

    Feature-99055-BackendControllerServiceTagAsAttribute.rst:7 Reply

    Done
  14. Stefan Bürk updated the commit message in patch set 13 11/13/22, 01:36

  15. core-ci voted on patch set 13 V +1 11/13/22, 01:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33661

  16. Stefan Bürk updated the commit message in patch set 14 11/13/22, 01:46

  17. core-ci voted on patch set 14 V +1 11/13/22, 01:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33662

  18. Stefan Bürk uploaded patch set 15 11/13/22, 02:41

  19. core-ci voted on patch set 15 V +1 11/13/22, 02:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33664

  20. Stefan Bürk rebased onto patch set 16 V +1 11/22/22, 23:41

  21. core-ci voted on patch set 16 V +1 11/22/22, 23:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34089

  22. Stefan Bürk voted on patch set 16 V +1 CR +1 11/23/22, 00:45

  23. Stefan Bürk commented on patch set 16 11/23/22, 00:45

    Nice patch. Thanks for the hard work on it @Bastien.
  24. Benni Mack voted on patch set 16 V +2 CR +2 11/23/22, 14:01

  25. Benni Mack merged patch set 17 11/23/22, 14:01