in2code-de / powermail

This is the official repository of the TYPO3 extension powermail! Powermail is a well-known, editor-friendly, powerful and easy mailform extension for TYPO3
https://in2code.de
88 stars 174 forks source link

DependencyInjection in DataProcessor #849

Closed tgriessbach closed 1 year ago

tgriessbach commented 1 year ago

Hi, we have a problem after updating an older system to this:

We used a DataProcessor that extends In2code\Powermail\DataProcessor\AbstractDataProcessor and we used Constructor injection to get a repository in there. In TYPO3 10 with PHP 7 that worked fine.

But it does not work anymore because it is not possible now to override a __construct() with different arguments.

Now we tried Method injection like here: https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ApiOverview/DependencyInjection/Index.html#method-injection

But for that you have to set autowire: true and that collides with the __construct() again:

Cannot autowire service "Vendor\Extension\DataProcessor\CustomDataProcessor": 
argument "$configuration" of method "In2code\Powermail\DataProcessor\AbstractDataProcessor::__construct()" 
is type-hinted "array", you should configure its value explicitly.

Do you have any tips for us how to get DependencyInjection working for this DataProcessor?

einpraegsam commented 1 year ago

Hi,

please don't use github issues for support questions to keep the issue board as small as possible. Slack or Stackoverflow would be the best location for this. I'm not a DI pro yet so I have no quick answer for you (except using GeneralUtitlity::makeInstance()).

Thx, Alex

runepiper commented 9 months ago

@tgriessbach We do have a similar problem. Could you resolve your problem it?

tgriessbach commented 6 months ago

Hi @runepiper , sorry because the ticket was closed I didn't see your reply.

We used the DataProcessor to add data to emails. So we could resolve the problem by moving the logic from the DataProcessor to a PowermailSendMailSignal that is connected to the createEmailBodyBeforeRender slot. There the __construct injection works.