From 76bd005b45d974002d2b2b58e364097a34ba77d6 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Sun, 21 Aug 2022 22:41:31 +0200 Subject: [PATCH] add Doctrine Connection bridge --- Doctrine/DBAL/ConnectionBridge.php | 42 +++++++++++++++++++++ Doctrine/DBAL/ConnectionBridgeInterface.php | 28 ++++++++++++++ services.yaml | 6 ++- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 Doctrine/DBAL/ConnectionBridge.php create mode 100644 Doctrine/DBAL/ConnectionBridgeInterface.php diff --git a/Doctrine/DBAL/ConnectionBridge.php b/Doctrine/DBAL/ConnectionBridge.php new file mode 100644 index 0000000..354958b --- /dev/null +++ b/Doctrine/DBAL/ConnectionBridge.php @@ -0,0 +1,42 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\OxidServiceBridges\Doctrine\DBAL; + +use Doctrine\DBAL\Connection; + +class ConnectionBridge implements ConnectionBridgeInterface +{ + /** + * @var Connection + */ + private $connection; + + public function __construct( + Connection $connection + ) { + $this->connection = $connection; + } + + /** + * @param string $moduleId + * @param int $shopId + * @return Connection + */ + public function getConnection(): Connection + { + return $this->connection; + } +} diff --git a/Doctrine/DBAL/ConnectionBridgeInterface.php b/Doctrine/DBAL/ConnectionBridgeInterface.php new file mode 100644 index 0000000..1702176 --- /dev/null +++ b/Doctrine/DBAL/ConnectionBridgeInterface.php @@ -0,0 +1,28 @@ + + * @link https://www.oxidmodule.com + */ + +declare(strict_types=1); + +namespace D3\OxidServiceBridges\Doctrine\DBAL; + +use Doctrine\DBAL\Connection; + +interface ConnectionBridgeInterface +{ + /** + * @param string $moduleId + * @param int $shopId + * @return string + */ + public function getConnection(): Connection; +} \ No newline at end of file diff --git a/services.yaml b/services.yaml index b525551..e00d103 100644 --- a/services.yaml +++ b/services.yaml @@ -1,8 +1,10 @@ services: _defaults: autowire: true - public: false + public: true + + D3\OxidServiceBridges\Doctrine\DBAL\ConnectionBridgeInterface: + class: D3\OxidServiceBridges\Doctrine\DBAL\ConnectionBridge D3\OxidServiceBridges\Internal\Framework\Module\Path\ModulePathResolverBridgeInterface: class: D3\OxidServiceBridges\Internal\Framework\Module\Path\ModulePathResolverBridge - public: true