FailoverTransport.php 944 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Component\Mailer\Transport;
  11. /**
  12. * Uses several Transports using a failover algorithm.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class FailoverTransport extends RoundRobinTransport
  17. {
  18. private $currentTransport;
  19. protected function getNextTransport(): ?TransportInterface
  20. {
  21. if (null === $this->currentTransport || $this->isTransportDead($this->currentTransport)) {
  22. $this->currentTransport = parent::getNextTransport();
  23. }
  24. return $this->currentTransport;
  25. }
  26. protected function getInitialCursor(): int
  27. {
  28. return 0;
  29. }
  30. protected function getNameSymbol(): string
  31. {
  32. return 'failover';
  33. }
  34. }