1 | <?php |
||
14 | class ConnectionFactory extends AbstractFactory |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * {@inheritDoc} |
||
19 | */ |
||
20 | 22 | protected function create(ContainerInterface $container, $config) |
|
21 | { |
||
22 | 22 | $factoryName = $config['factory']; |
|
23 | 22 | $handler = $container->get($config['handler']); |
|
24 | 22 | $loggers = $container->get($config['loggers']); |
|
25 | 22 | $serializer = $this->getServiceOrClassObject($container, $config['serializer']); |
|
26 | 22 | $params = $this->getConnectionParametersFromConfiguration($config); |
|
27 | 22 | $connectionFactory = new $factoryName($handler, $params, $serializer, $loggers['logger'], $loggers['tracer']); |
|
28 | |||
29 | 22 | if (!$connectionFactory instanceof ConnectionFactoryInterface) { |
|
30 | 1 | throw new ServiceNotCreatedException(sprintf( |
|
31 | 1 | "The '%s' class does not implements %s", |
|
32 | 1 | $factoryName, |
|
33 | ConnectionFactoryInterface::class |
||
34 | 1 | )); |
|
35 | } |
||
36 | 21 | return $connectionFactory; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * {@inheritDoc} |
||
41 | */ |
||
42 | 22 | public function getServiceType() |
|
46 | |||
47 | /** |
||
48 | * @param array|ArrayObject|ZendArrayObject $config |
||
49 | * @return array |
||
50 | */ |
||
51 | 22 | private function getConnectionParametersFromConfiguration($config) |
|
55 | |||
56 | } |
||
57 |