derhansen / xclass_di

TYPO3 Test Extension to evaluate DI when xclassing an extbase controller
1 stars 1 forks source link

solution #1

Open lukasniestroj opened 3 years ago

lukasniestroj commented 3 years ago

Hi @derhansen ,

I stumbled upon the same issue today. After some research I came to the solution to add a reference to the Services.yaml.

TYPO3\CMS\Belog\Controller\BackendLogController: '@Derhansen\XclassDi\Controller\ExtendedBackendLogController'

In my case I had an overwritten Controller from ext:news.

derhansen commented 3 years ago

Cool, thanks a lot for providing the solution to the problem. I will add an example to the TYPO3 docs so this is documented.

derhansen commented 3 years ago

PR: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/1403

stoppeye commented 1 year ago

I was happy to find this hint and tried it in v12 with my own xlcassed version of \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController. I'm pretty sure I did it exactly as shown in your sample extension (checked + double-checked). But it seems to behave differently. As soon as I add the reference in Services.yaml, I get something like:

Too few arguments to function MyVendor\MyExt\Scheduler\MyExtController::__construct(), 0 passed in /typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 2969 and exactly 9 expected

Without the extra line in Services.yaml I get the error with something like 8 passed in /typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 3000 and exactly 9 expected, which is at least what you would expect. So the reference in Services.yaml did have an effect, just not the one I had hoped for...

Am I doing something wrong or has something changed in V12? Does the new tagging of the controller with #[BackendController] play into this? Or am I just too stupid to replicate your example?

mschwemer commented 6 months ago

I have the same issue like @stoppeye and did not find a solution.

Any hints would be appreciated.

I am currently working on a v12 compatible upgrade of EXT:be_acl and need to modify the PermissionController,

lukasniestroj commented 6 months ago

@mschwemer @stoppeye If you have autowire and autoconfigure enabled for your classes try to disable them for the XClass namespaces, also they should be private. I did not tested this with all variants but it helped if the base class had private services in DI

stoppeye commented 6 months ago

@lukasniestroj: thanks for your hint! Unfortunately I can't really test the use case I had, when I made my comment. I have found a completely different solution for my problem that doesn't require XClass anymore.