Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExchangeRepository.php
Go to the documentation of this file.
1 <?php
7 
9 {
13  private $objectManager;
14 
18  private $exchangeFactory;
19 
25  private $exchangePool = [];
26 
33  public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, array $exchanges = [])
34  {
35  $this->objectManager = $objectManager;
36  }
37 
43  public function getByConnectionName($connectionName)
44  {
45  if (!isset($this->exchangePool[$connectionName])) {
46  $exchange = $this->getExchangeFactory()->create($connectionName);
47  $this->exchangePool[$connectionName] = $exchange;
48  }
49  return $this->exchangePool[$connectionName];
50  }
51 
58  private function getExchangeFactory()
59  {
60  if ($this->exchangeFactory === null) {
61  $this->exchangeFactory = $this->objectManager->get(ExchangeFactoryInterface::class);
62  }
63  return $this->exchangeFactory;
64  }
65 }
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, array $exchanges=[])
$objectManager
Definition: bootstrap.php:17