SyncTransportFactory.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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\Messenger\Transport\Sync;
  11. use Symfony\Component\Messenger\MessageBusInterface;
  12. use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
  13. use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
  14. use Symfony\Component\Messenger\Transport\TransportInterface;
  15. /**
  16. * @author Ryan Weaver <ryan@symfonycasts.com>
  17. */
  18. class SyncTransportFactory implements TransportFactoryInterface
  19. {
  20. private $messageBus;
  21. public function __construct(MessageBusInterface $messageBus)
  22. {
  23. $this->messageBus = $messageBus;
  24. }
  25. public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
  26. {
  27. return new SyncTransport($this->messageBus);
  28. }
  29. public function supports(string $dsn, array $options): bool
  30. {
  31. return 0 === strpos($dsn, 'sync://');
  32. }
  33. }