QueueFactory.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Amqp;
  7. /**
  8. * Factory class for @see \Magento\Framework\Amqp\Queue
  9. *
  10. * @api
  11. * @since 102.0.1
  12. */
  13. class QueueFactory implements \Magento\Framework\MessageQueue\QueueFactoryInterface
  14. {
  15. /**
  16. * Object Manager instance
  17. *
  18. * @var \Magento\Framework\ObjectManagerInterface
  19. */
  20. private $objectManager = null;
  21. /**
  22. * Instance name to create
  23. *
  24. * @var string
  25. */
  26. private $instanceName = null;
  27. /**
  28. * @var ConfigPool
  29. */
  30. private $configPool;
  31. /**
  32. * Initialize dependencies.
  33. *
  34. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  35. * @param ConfigPool $configPool
  36. * @param string $instanceName
  37. */
  38. public function __construct(
  39. \Magento\Framework\ObjectManagerInterface $objectManager,
  40. ConfigPool $configPool,
  41. $instanceName = \Magento\Framework\Amqp\Queue::class
  42. ) {
  43. $this->objectManager = $objectManager;
  44. $this->configPool = $configPool;
  45. $this->instanceName = $instanceName;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. * @since 102.0.1
  50. */
  51. public function create($queueName, $connectionName)
  52. {
  53. return $this->objectManager->create(
  54. $this->instanceName,
  55. [
  56. 'amqpConfig' => $this->configPool->get($connectionName),
  57. 'queueName' => $queueName
  58. ]
  59. );
  60. }
  61. }