[Improvement] Mail: Adapter for Mustache Engine#11173
[Improvement] Mail: Adapter for Mustache Engine#11173fhelfer wants to merge 1 commit intoILIAS-eLearning:release_11from
Conversation
| $dic['logging.information_generator'] = static fn($c): Logging\AdditionalInformationGenerator => | ||
| new Logging\AdditionalInformationGenerator( | ||
| (new \ilMustacheFactory())->getBasicEngine(), | ||
| $DIC->mail()->templateEngineFactory()->getBasicEngine(), |
There was a problem hiding this comment.
I think we should also provide an array key-access option here.
Option 1) We could make the mail template engine accessible via an array key TemplateEngineFactoryInterface::class in the $DIC.
Option 2, which I prefer) We use \ILIAS\Mail\Service\MailService to publish our mail subsystem to the $DIC (outlook: $define), so others, like Stephan in this case, can grab the template engine factory from there.
Of course, it is generally questionable (of course I am aware of the reasons) why other components are interested in the template engine of the mail component, but I think we will not get rid of this anytime soon.
There was a problem hiding this comment.
Yes, please, could we have this as an array access?
There was a problem hiding this comment.
Thank you very much for the PR!
I would love it, if we could follow @mjansenDatabay suggestion, but other than that I welcome this change. (Approval for both Test and User, although I'm not sure that Test actually depends on the Mail-Template-Engine, I think it depends on an alternative template engine based on mustache, but this is for later).
Best,
@kergomard
| $dic['logging.information_generator'] = static fn($c): Logging\AdditionalInformationGenerator => | ||
| new Logging\AdditionalInformationGenerator( | ||
| (new \ilMustacheFactory())->getBasicEngine(), | ||
| $DIC->mail()->templateEngineFactory()->getBasicEngine(), |
There was a problem hiding this comment.
Yes, please, could we have this as an array access?
|
Hi @kergomard, we are currently working on removing the We hope the changes are understandable and acceptable from your perspective, and that the motivation behind this refactoring is clear. We would very much appreciate it if you could briefly review the modifications affecting your components. Best regards, |
|
Thanks @kergomard, lightning fast, even too fast for me! 😉 |
Introduces
TemplateEngineInterfaceandTemplateEngineFactoryInterfacein the Mail component, plus a Mustache-based implementation (MustacheTemplateEngine, MustacheTemplateEngineFactory).Mail, User, and Test now depend on these interfaces instead of Mustache_Engine or ilMustacheFactory.
Why: Direct dependencies on third-party libraries make the code harder to test, maintain, and change. An abstraction layer lets us mock the template engine in tests, swap implementations later, and keep the Mail component independent of a specific library.
ilMustacheFactory is removed. Use $DIC->mail()->templateEngineFactory() instead of mustacheFactory().