|
6 | 6 |
|
7 | 7 | use InvalidArgumentException;
|
8 | 8 | use LogicException;
|
9 |
| -use ReflectionMethod; |
10 |
| -use ReflectionProperty; |
11 |
| -use Symfony\Bundle\FrameworkBundle\Test\TestContainer; |
12 | 9 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
13 | 10 | use Symfony\Component\HttpFoundation\Response;
|
14 | 11 | use Symfony\Component\HttpKernel\HttpKernelBrowser;
|
@@ -114,32 +111,16 @@ private function getProfiler(): ?Profiler
|
114 | 111 |
|
115 | 112 | private function persistDoctrineConnections(): void
|
116 | 113 | {
|
117 |
| - if (!$this->container->hasParameter('doctrine.connections')) { |
| 114 | + $connections = $this->container->getParameter('doctrine.connections'); |
| 115 | + if (!is_array($connections)) { |
118 | 116 | return;
|
119 | 117 | }
|
120 | 118 |
|
121 |
| - if ($this->container instanceof TestContainer) { |
122 |
| - $method = new ReflectionMethod($this->container, 'getPublicContainer'); |
123 |
| - $publicContainer = $method->invoke($this->container); |
124 |
| - } else { |
125 |
| - $publicContainer = $this->container; |
126 |
| - } |
127 |
| - |
128 |
| - if (!is_object($publicContainer) || !method_exists($publicContainer, 'getParameterBag')) { |
129 |
| - return; |
130 |
| - } |
131 |
| - |
132 |
| - $target = property_exists($publicContainer, 'parameters') |
133 |
| - ? $publicContainer |
134 |
| - : $publicContainer->getParameterBag(); |
135 |
| - |
136 |
| - if (!is_object($target) || !property_exists($target, 'parameters')) { |
137 |
| - return; |
| 119 | + /** @var array<array-key, non-empty-string> $connections */ |
| 120 | + foreach ($connections as $connectionId) { |
| 121 | + if ($this->container->has($connectionId)) { |
| 122 | + $this->persistentServices[$connectionId] = $this->container->get($connectionId); |
| 123 | + } |
138 | 124 | }
|
139 |
| - $prop = new ReflectionProperty($target, 'parameters'); |
140 |
| - |
141 |
| - $params = (array) $prop->getValue($target); |
142 |
| - unset($params['doctrine.connections']); |
143 |
| - $prop->setValue($target, $params); |
144 | 125 | }
|
145 | 126 | }
|
0 commit comments