Share PDO connection between Doctrine and legacy ORM

[MAILPOET-2014]
This commit is contained in:
Jan Jakeš
2019-07-18 15:40:15 +02:00
committed by M. Shull
parent a07043cfb4
commit 0045683d92
8 changed files with 41 additions and 130 deletions

View File

@ -0,0 +1,24 @@
<?php
namespace MailPoet\Config;
use MailPoetVendor\Doctrine\DBAL\Connection;
use MailPoetVendor\Psr\Container\ContainerInterface;
if (!defined('ABSPATH')) exit;
class DatabaseInitializer {
private $di_container;
function __construct(ContainerInterface $di_container) {
$this->di_container = $di_container;
}
function initializeConnection() {
$connection = $this->di_container->get(Connection::class);
// pass the same PDO connection to legacy Database object
$database = new Database();
$database->init($connection->getWrappedConnection());
}
}