Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c9af8d

Browse files
committed
[simple-client] Add ability to pass container builder.
1 parent f4b97d5 commit 5c9af8d

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

pkg/simple-client/SimpleClient.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@
2626
use Interop\Queue\PsrContext;
2727
use Interop\Queue\PsrProcessor;
2828
use Symfony\Component\DependencyInjection\ContainerBuilder;
29+
use Symfony\Component\DependencyInjection\ContainerInterface;
2930

3031
final class SimpleClient
3132
{
3233
/**
33-
* @var ContainerBuilder
34+
* @var ContainerInterface
3435
*/
3536
private $container;
3637

38+
/**
39+
* @var array|string
40+
*/
41+
private $config;
42+
3743
/**
3844
* The config could be a transport DSN (string) or an array, here's an example of a few DSNs:.
3945
*
@@ -73,11 +79,13 @@ final class SimpleClient
7379
* ]
7480
*
7581
*
76-
* @param string|array $config
82+
* @param string|array $config
83+
* @param ContainerBuilder|null $container
7784
*/
78-
public function __construct($config)
85+
public function __construct($config, ContainerBuilder $container = null)
7986
{
80-
$this->container = $this->buildContainer($config);
87+
$this->container = $this->buildContainer($config, $container ?: new ContainerBuilder());
88+
$this->config = $config;
8189
}
8290

8391
/**
@@ -252,16 +260,16 @@ public function getRouterProcessor()
252260
}
253261

254262
/**
255-
* @param array|string $config
263+
* @param array|string $config
264+
* @param ContainerBuilder $container
256265
*
257-
* @return ContainerBuilder
266+
* @return ContainerInterface
258267
*/
259-
private function buildContainer($config)
268+
private function buildContainer($config, ContainerBuilder $container)
260269
{
261270
$config = $this->buildConfig($config);
262271
$extension = $this->buildContainerExtension();
263272

264-
$container = new ContainerBuilder();
265273
$container->registerExtension($extension);
266274
$container->loadFromExtension($extension->getAlias(), $config);
267275

0 commit comments

Comments
 (0)