Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConnectionFactory.php
Go to the documentation of this file.
1 <?php
8 
12 
18 {
22  private $resourceConnection;
23 
27  private $objectManager;
28 
33  public function __construct(
34  ResourceConnection $resourceConnection,
35  ObjectManagerInterface $objectManager
36  ) {
37  $this->resourceConnection = $resourceConnection;
38  $this->objectManager = $objectManager;
39  }
40 
47  public function getConnection($connectionName)
48  {
49  $connection = $this->resourceConnection->getConnection($connectionName);
50  $connectionClassName = get_class($connection);
51  $configData = $connection->getConfig();
52  $configData['use_buffered_query'] = false;
53  unset($configData['persistent']);
54  return $this->objectManager->create(
55  $connectionClassName,
56  [
57  'config' => $configData
58  ]
59  );
60  }
61 }
$objectManager
Definition: bootstrap.php:17
__construct(ResourceConnection $resourceConnection, ObjectManagerInterface $objectManager)
$connection
Definition: bulk.php:13