本文整理匯總了PHP中Symfony\Component\DependencyInjection\Container::extend方法的典型用法代碼示例。如果您正苦於以下問題:PHP Container::extend方法的具體用法?PHP Container::extend怎麽用?PHP Container::extend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\Container
的用法示例。
在下文中一共展示了Container::extend方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: register
public function register(Container $container)
{
$container["data_collectors.swiftmailer.message_logger"] = function () {
return new \Swift_Plugins_MessageLogger();
};
$container["data_collectors.swiftmailer.collector_container"] = function (Container $app) {
$container = new SymfonyContainer();
$container->setParameter("swiftmailer.mailers", ["default" => $app["swiftmailer.options"]]);
$container->setParameter("swiftmailer.default_mailer", "default");
$container->setParameter("swiftmailer.mailer.default.spool.enabled", $app["swiftmailer.use_spool"]);
$container->set("swiftmailer.mailer.default.plugin.messagelogger", $app["data_collectors.swiftmailer.message_logger"]);
return $container;
};
$container->extend('mailer', function (\Swift_Mailer $mailer, Container $container) {
$mailer->registerPlugin($container['data_collectors.swiftmailer.message_logger']);
return $mailer;
});
$container->extend('data_collectors', function (array $collectors, Container $container) {
$collectors['swiftmailer'] = function ($container) {
return new MessageDataCollector($container["data_collectors.swiftmailer.collector_container"]);
};
return $collectors;
});
$container->extend('data_collector.templates', function ($templates) {
$templates[] = ['swiftmailer', '@Swiftmailer/Collector/swiftmailer.html.twig'];
return $templates;
});
$container->extend('twig.loader.filesystem', function (\Twig_Loader_Filesystem $loader) {
$loader->addPath(dirname(dirname((new \ReflectionClass(MessageDataCollector::class))->getFileName())) . '/Resources/views', 'Swiftmailer');
return $loader;
});
}