Skip to content

Commit

Permalink
Merge pull request #17 from inspector-apm/symfony_v4_compatibility
Browse files Browse the repository at this point in the history
Symfony v4 compatibility
  • Loading branch information
ilvalerione authored Jul 5, 2021
2 parents 017e466 + 89896d1 commit 305fc16
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"require": {
"php": ">=7.2.5",
"inspector-apm/inspector-php": "^3.6",
"symfony/config": "^5.2",
"symfony/dependency-injection": "^5.2",
"symfony/http-kernel": "^5.2",
"symfony/event-dispatcher": "^5.2",
"symfony/console": "^5.2",
"symfony/framework-bundle": "^5.2",
"symfony/yaml": "^5.2",
"symfony/security-bundle": "^5.2"
"symfony/config": "^4.4|^5.2",
"symfony/dependency-injection": "^4.4|^5.2",
"symfony/http-kernel": "^4.4|^5.2",
"symfony/event-dispatcher": "^4.4|^5.2",
"symfony/console": "^4.4|^5.2",
"symfony/framework-bundle": "^4.4|^5.2",
"symfony/yaml": "^4.4|^5.2",
"symfony/security-bundle": "^4.4|^5.2"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.4",
"symfony/framework-bundle": "^5.3.2",
"symfony/framework-bundle": "^4.4|^5.2",
"phpunit/phpunit": "^9.5",
"symfony/test-pack": "^1.0"
},
Expand Down
11 changes: 8 additions & 3 deletions src/DependencyInjection/Compiler/DoctrineDBALCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Logging\LoggerChain;
use Doctrine\DBAL\SQLParserUtils;
use Inspector\Symfony\Bundle\Inspectable\Doctrine\DBAL\Logging\InspectableSQLLogger;
use OutOfBoundsException;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand Down Expand Up @@ -51,9 +52,13 @@ public function process(ContainerBuilder $container)
// doctrine/dbal < 2.10.0
$chainLogger->addMethodCall('addLogger', [$logger]);
} else {
$loggers = $chainLogger->getArgument(0);
array_push($loggers, $logger);
$chainLogger->replaceArgument(0, $loggers);
try {
$loggers = $chainLogger->getArgument(0);
array_push($loggers, $logger);
$chainLogger->replaceArgument(0, $loggers);
} catch (OutOfBoundsException $exception) {
$chainLogger->addArgument([$logger]);
}
}

$container->getDefinition(sprintf('doctrine.dbal.%s_connection.configuration', $name))->addMethodCall('setSQLLogger', [$logger]);
Expand Down
5 changes: 4 additions & 1 deletion src/Listeners/ConsoleEventsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ public static function getSubscribedEvents(): array
ConsoleEvents::COMMAND => ['onConsoleStart', 9999],
ConsoleEvents::ERROR => ['onConsoleError', 128],
ConsoleEvents::TERMINATE => ['onConsoleTerminate', 0],
ConsoleEvents::SIGNAL => ['onConsoleSignal', 0],
];

if (defined('Symfony\Component\Console::CONSOLE_SIGNAL')) {
$listeners[ConsoleEvents::SIGNAL] = ['onConsoleSignal', 0];
}

return $listeners;
}

Expand Down

0 comments on commit 305fc16

Please sign in to comment.