этого создал отдельный класс врапер.
В doctrine.yaml:
doctrine:
dbal:
connections:
default:
wrapper_class: App\Service\Database\ExtendedCustomConnection
Сам класс
namespace App\Service\Database;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection as Connection;
use Doctrine\DBAL\Driver;
use Symfony\Component\Yaml\Yaml;
class ExtendedCustomConnect extends Connection
{
public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null)
{
$config = Yaml::parseFile(__DIR__.'/../../../config.yaml');
$params['dbname'] = $config['connections']['db'];
$params['host'] = $config['connections']['address'];
$params['port'] = $config['connections']['port'];
$params['user'] = $config['connections']['username'];
$params['password'] = $config['connections']['password'];
parent::__construct($params, $driver, $config, $eventManager);
}
}
Но получаю ошибку
request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "The given 'wrapperClass' App\Service\Database\ExtendedCustomConnection has to be a subtype of \Doctrine\DBAL\Connection."
Почему?
App\Service\Database\ExtendedCustomConnect !== App\Service\Database\ExtendedCustomConnection
Обсуждают сегодня