vendor/symfony/swiftmailer-bundle/DependencyInjection/SmtpTransportConfigurator.php line 21

Open in your IDE?
  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\SwiftmailerBundle\DependencyInjection;
  11. use Symfony\Component\Routing\RequestContext;
  12. class SmtpTransportConfigurator
  13. {
  14. private $localDomain;
  15. private $requestContext;
  16. public function __construct($localDomain, RequestContext $requestContext = null)
  17. {
  18. $this->localDomain = $localDomain;
  19. $this->requestContext = $requestContext;
  20. }
  21. /**
  22. * Sets the local domain based on the current request context.
  23. */
  24. public function configure(\Swift_Transport_AbstractSmtpTransport $transport)
  25. {
  26. if ($this->localDomain) {
  27. $transport->setLocalDomain($this->localDomain);
  28. } elseif ($this->requestContext) {
  29. $transport->setLocalDomain($this->requestContext->getHost());
  30. }
  31. }
  32. }