Project

General

Profile

Actions

Bug #96370

closed

@TYPO3\CMS\Extbase\Annotation\Inject not working with Services.yaml in TYPO3 10.4.21

Added by Patrik Lang over 2 years ago. Updated over 2 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2021-12-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hi, when I register a service through Services.yaml the dependency injection with @TYPO3\CMS\Extbase\Annotation\Inject in my controllers aren't working anymore.

I have removed and changed parts of the Services.yaml and figured out that the namespace to Classes folder configuration causes this error.

Removing this configuration snippet results in working dependency injection:

Vendor\Namespace\:
resource: '../Classes/*'

So I guess there is a bug leading to this.

For now I got the workaround by injecting the needed classes with inject methods, but this should work anyway

Actions #1

Updated by Simon Schaufelberger over 2 years ago

Best practice is either inject Methods or Constructor injection.

Actions #2

Updated by Benjamin Franzke over 2 years ago

  • Status changed from New to Rejected

That is true, TYPO3\CMS\Extbase\Annotation\Inject is not supported for Symfony DI based dependency injection.
Therefore Symfony DI is opt-in via Services.yaml.
If you disabled injection via Services.yaml, the extbase objectmananger is used instead (legacy mode).

You need to migrate to constructor or injectMethod() injection, which are supported in Symfony DI mode.

Note: This will also help with upgraded to v12, as https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.html#description

Actions

Also available in: Atom PDF