Skip to content

Commit

Permalink
feat: Add aliases for each driver and its session in Neo4jExtension.php
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Oct 30, 2024
1 parent d0283a1 commit f889710
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/DependencyInjection/Neo4jExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Neo4j\Neo4jBundle\DependencyInjection;

use Laudis\Neo4j\Contracts\DriverInterface;
use Laudis\Neo4j\Contracts\SessionInterface;
use Neo4j\Neo4jBundle\Collector\Neo4jDataCollector;
use Neo4j\Neo4jBundle\EventHandler;
use Neo4j\Neo4jBundle\EventListener\Neo4jProfileListener;
Expand Down Expand Up @@ -58,6 +60,24 @@ public function load(array $configs, ContainerBuilder $container): ContainerBuil
$container->getDefinition('neo4j.driver')
->setArgument(0, $defaultAlias);

foreach ($mergedConfig['drivers'] as $driverConfig) {
$container
->setDefinition(
'neo4j.driver.'.$driverConfig['alias'],
(new Definition(DriverInterface::class))
->setFactory([new Reference('neo4j.client'), 'getDriver'])
->setArgument(0, $driverConfig['alias'])
);

$container
->setDefinition(
'neo4j.session.'.$driverConfig['alias'],
(new Definition(SessionInterface::class))
->setFactory([new Reference('neo4j.driver.'.$driverConfig['alias']), 'createSession'])
->setShared(false)
);
}

$enabledProfiles = [];
foreach ($mergedConfig['drivers'] as $driver) {
if (true === $driver['profiling'] || (null === $driver['profiling'] && $container->getParameter(
Expand Down

0 comments on commit f889710

Please sign in to comment.