use Symfony\Component\DependencyInjection\Definition; $definition = new Definition('Swift_Mailer', [ new Reference('mailer.transport'), ]); $definition->setFactory(['Swift_MailerFactory', 'createMailer']); $containerBuilder->setDefinition('mailer', $definition); // Retrieving the Factory Service Definition $factoryDefinition = $containerBuilder->getDefinition('mailer')->getFactoryService();
use Symfony\Component\DependencyInjection\Definition; $definition = new Definition('NewsletterGenerator', [ new Reference('markdown_to_html_converter'), ]); $definition->setFactory([new Reference('markdown_to_html_converter'), 'createConverter']); $containerBuilder->setDefinition('newsletter_generator', $definition); // Retrieving the Factory Service Definition $factoryDefinition = $containerBuilder->getDefinition('newsletter_generator')->getFactoryService();In both examples, the getFactoryService method is used to retrieve the Factory Service Definition for the given service definition. This allows us to easily access and modify the factory service if needed.