Skip to content

Commit

Permalink
Fix some deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Dec 4, 2023
1 parent 24a79de commit 8f7b23d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 54 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=7.4",
"doctrine/orm": "^2.13",
"doctrine/orm": "^2.14",
"doctrine/dbal": "^3.5",
"symfony/console": ">=3.0.0",
"symfony/cache": ">=4.4.0",
Expand Down
22 changes: 12 additions & 10 deletions src/storage/connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
use midgard\portable\mapping\factory;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\ORMSetup;
use Doctrine\DBAL\Logging\Connection as connection_logger;
use Doctrine\DBAL\Logging\Middleware;

class connection
{
Expand Down Expand Up @@ -181,26 +183,26 @@ public static function startup()
$config->setMetadataDriverImpl($driver);
$config->setClassMetadataFactoryName(factory::class);

$midgard = midgard_connection::get_instance();
$level = self::$loglevels[$midgard->get_loglevel()];
if ($level === Logger::DEBUG) {
$logger = new Logger('doctrine');
$logger->pushHandler(new StreamHandler($midgard->config->logfilename, $level));
$config->setMiddlewares([new Middleware($logger)]);
}

if (!array_key_exists('charset', $db_config)) {
$db_config['charset'] = 'utf8';
}

$em = \Doctrine\ORM\EntityManager::create($db_config, $config);
$connection = \Doctrine\DBAL\DriverManager::getConnection($db_config, $config);
$em = new EntityManager($connection, $config);
$em->getFilters()->enable('softdelete');
$em->getEventManager()->addEventSubscriber(new subscriber);

Type::overrideType(Types::DATETIME_MUTABLE, datetime::class);
Type::overrideType(Types::DATE_MUTABLE, datetime::class);

$midgard = midgard_connection::get_instance();
$level = self::$loglevels[$midgard->get_loglevel()];
if ($level === Logger::DEBUG) {
$logger = new Logger('doctrine');
$logger->pushHandler(new StreamHandler($midgard->config->logfilename, $level));

$em->getConnection()->getConfiguration()->setSQLLogger(new sqllogger($logger));
}

self::$instance = new static($em, $driver->get_namespace());
}

Expand Down
43 changes: 0 additions & 43 deletions src/storage/sqllogger.php

This file was deleted.

0 comments on commit 8f7b23d

Please sign in to comment.