RedisTransportFactory.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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\Bridge\Redis\Transport;
  11. use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
  12. use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
  13. use Symfony\Component\Messenger\Transport\TransportInterface;
  14. /**
  15. * @author Alexander Schranz <alexander@suluio>
  16. * @author Antoine Bluchet <soyuka@gmail.com>
  17. */
  18. class RedisTransportFactory implements TransportFactoryInterface
  19. {
  20. public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
  21. {
  22. unset($options['transport_name']);
  23. return new RedisTransport(Connection::fromDsn($dsn, $options), $serializer);
  24. }
  25. public function supports(string $dsn, array $options): bool
  26. {
  27. return 0 === strpos($dsn, 'redis://');
  28. }
  29. }
  30. class_alias(RedisTransportFactory::class, \Symfony\Component\Messenger\Transport\RedisExt\RedisTransportFactory::class);