ExchangeFactory.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Exchange
  9. *
  10. * @api
  11. * @since 102.0.1
  12. */
  13. class ExchangeFactory implements \Magento\Framework\MessageQueue\ExchangeFactoryInterface
  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\Exchange::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($connectionName, array $data = [])
  52. {
  53. $data['amqpConfig'] = $this->configPool->get($connectionName);
  54. return $this->objectManager->create(
  55. $this->instanceName,
  56. $data
  57. );
  58. }
  59. }