|
22 | 22 | use Symfony\Component\DependencyInjection\Definition; |
23 | 23 | use Symfony\Component\DependencyInjection\Reference; |
24 | 24 |
|
| 25 | +/** |
| 26 | + * Class PostgresqlCompilerPass. |
| 27 | + */ |
25 | 28 | class PostgresqlCompilerPass implements CompilerPassInterface |
26 | 29 | { |
27 | 30 | /** |
28 | 31 | * You can modify the container here before it is dumped to PHP code. |
29 | 32 | */ |
30 | 33 | public function process(ContainerBuilder $container) |
31 | 34 | { |
32 | | - $connectionsConfiguration = $container->getParameter('postgresql.connections_configuration'); |
33 | | - if (empty($connectionsConfiguration)) { |
| 35 | + $clientsConfiguration = $container->getParameter('postgresql.clients_configuration'); |
| 36 | + if (empty($clientsConfiguration)) { |
34 | 37 | return; |
35 | 38 | } |
36 | 39 |
|
37 | | - foreach ($connectionsConfiguration as $connectionName => $connectionConfiguration) { |
38 | | - $connectionAlias = $this->createConnection($container, $connectionConfiguration); |
| 40 | + foreach ($clientsConfiguration as $clientName => $clientConfiguration) { |
| 41 | + $clientAlias = $this->createclient($container, $clientConfiguration); |
39 | 42 |
|
40 | 43 | $container->setAlias( |
41 | | - "postgresql.{$connectionName}_connection", |
42 | | - $connectionAlias |
| 44 | + "postgresql.{$clientName}_client", |
| 45 | + $clientAlias |
43 | 46 | ); |
44 | 47 |
|
45 | | - $container->setAlias(Client::class, $connectionAlias); |
46 | | - $container->registerAliasForArgument($connectionAlias, Client::class, "{$connectionName} connection"); |
| 48 | + $container->setAlias(Client::class, $clientAlias); |
| 49 | + $container->registerAliasForArgument($clientAlias, Client::class, "{$clientName} client"); |
47 | 50 | } |
48 | 51 | } |
49 | 52 |
|
50 | 53 | /** |
51 | | - * Create connection and return it's reference. |
| 54 | + * Create client and return it's reference. |
52 | 55 | * |
53 | 56 | * @param ContainerBuilder $container |
54 | 57 | * @param array $configuration |
55 | 58 | * |
56 | 59 | * @return string |
57 | 60 | */ |
58 | | - private function createConnection( |
| 61 | + private function createclient( |
59 | 62 | ContainerBuilder $container, |
60 | 63 | array $configuration |
61 | 64 | ): string { |
62 | 65 | ksort($configuration); |
63 | | - $connectionHash = substr(md5(json_encode($configuration)), 0, 10); |
64 | | - $definitionName = "postgresql.connection.$connectionHash"; |
| 66 | + $clientHash = substr(md5(json_encode($configuration)), 0, 10); |
| 67 | + $definitionName = "postgresql.client.$clientHash"; |
65 | 68 |
|
66 | 69 | if (!$container->hasDefinition($definitionName)) { |
67 | 70 | $definition = new Definition(Client::class, [$configuration, new Reference(LoopInterface::class)]); |
|
0 commit comments