PageRenderTime 71ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/symfony/monolog-bundle/Symfony/Bundle/MonologBundle/DependencyInjection/Compiler/AddSwiftMailerTransportPass.php

https://github.com/Tiger76/CCIcommunityPrj
PHP | 55 lines | 32 code | 6 blank | 17 comment | 1 complexity | 0ca29b8b82636d5884a7de727112c806 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\DependencyInjection\Reference;
  14. /**
  15. * Sets the transport for Swiftmailer handlers depending on the existing
  16. * container definitions.
  17. *
  18. * @author Christian Flothmann <christian.flothmann@xabbuh.de>
  19. */
  20. class AddSwiftMailerTransportPass implements CompilerPassInterface
  21. {
  22. /**
  23. * {@inheritDoc}
  24. */
  25. public function process(ContainerBuilder $container)
  26. {
  27. $handlers = $container->getParameter('monolog.swift_mailer.handlers');
  28. foreach ($handlers as $id) {
  29. $definition = $container->getDefinition($id);
  30. if (
  31. $container->hasAlias('swiftmailer.transport.real') ||
  32. $container->hasDefinition('swiftmailer.transport.real')
  33. ) {
  34. $definition->addMethodCall(
  35. 'setTransport',
  36. array(new Reference('swiftmailer.transport.real'))
  37. );
  38. } elseif (
  39. $container->hasAlias('swiftmailer.transport') ||
  40. $container->hasDefinition('swiftmailer.transport')
  41. ) {
  42. $definition->addMethodCall(
  43. 'setTransport',
  44. array(new Reference('swiftmailer.transport'))
  45. );
  46. }
  47. }
  48. }
  49. }