Задача: Есть сервис (допустим, в чужом бандле), который нужно модифицировать. Решение: https://symfony.com/doc/current/service_container/service_decoration.html Конфиг:
#config/services.yamlservices: AppMailer: ~
#this replaces the old AppMailer definition with the new one, the #old definition is lostAppMailer: class: AppNewMailer Реализация: `// src/DecoratingMailer.php namespace App;
// ... // src/DecoratingMailer.php namespace App;
// ... use SymfonyComponentDependencyInjectionAttributeAsDecorator; use SymfonyComponentDependencyInjectionAttributeAutowireDecorated;
#[AsDecorator(decorates: Mailer::class)] class DecoratingMailer { public function __construct( #[AutowireDecorated] private object $inner, ) { }
// ... }`