mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Created new service which is the database connection but without the dbname, and used in in create db command
This commit is contained in:
21
module/Common/src/Doctrine/NoDbNameConnectionFactory.php
Normal file
21
module/Common/src/Doctrine/NoDbNameConnectionFactory.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\Doctrine;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class NoDbNameConnectionFactory
|
||||
{
|
||||
public const SERVICE_NAME = 'Shlinkio\Shlink\Common\Doctrine\NoDbNameConnection';
|
||||
|
||||
public function __invoke(ContainerInterface $container): Connection
|
||||
{
|
||||
$conn = $container->get(Connection::class);
|
||||
$params = $conn->getParams();
|
||||
unset($params['dbname']);
|
||||
|
||||
return new Connection($params, $conn->getDriver(), $conn->getConfiguration(), $conn->getEventManager());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user