1 | <?php |
||
14 | class ChannelChangerFactory |
||
15 | { |
||
16 | protected $config = null; |
||
17 | |||
18 | protected $handlerManager = null; |
||
19 | |||
20 | protected $processManager = null; |
||
21 | |||
22 | protected $formatterManager = null; |
||
23 | |||
24 | 1 | public function __invoke(ContainerInterface $container) |
|
36 | |||
37 | 7 | public function getMainConfig(ContainerInterface $container) |
|
42 | |||
43 | 7 | protected function getConfigArray(ContainerInterface $container) |
|
44 | { |
||
45 | // Symfony config is parameters. // |
||
46 | 7 | if (method_exists($container, 'getParameter') |
|
47 | 7 | && method_exists($container, 'hasParameter') |
|
48 | 7 | && $container->hasParameter('monolog') |
|
49 | ) { |
||
50 | 1 | return ['monolog' => $container->getParameter('monolog')]; |
|
51 | } |
||
52 | |||
53 | // Zend uses config key |
||
54 | 6 | if ($container->has('config')) { |
|
55 | 5 | return $container->get('config'); |
|
56 | } |
||
57 | |||
58 | // Slim Config comes from "settings" |
||
59 | 1 | if ($container->has('settings')) { |
|
60 | 1 | return ['monolog' => $container->get('settings')['monolog']]; |
|
61 | } |
||
62 | |||
63 | return []; |
||
64 | } |
||
65 | |||
66 | 2 | public function getHandlerManager(ContainerInterface $container) |
|
67 | { |
||
68 | 2 | $config = $this->getMainConfig($container); |
|
69 | 2 | $this->handlerManager = new HandlerManager( |
|
70 | 2 | $config, |
|
71 | 2 | new HandlerMapper(), |
|
72 | 2 | $container |
|
73 | ); |
||
74 | |||
75 | 2 | $this->handlerManager->setFormatterManager($this->getFormatterManager($container)); |
|
76 | 2 | $this->handlerManager->setProcessorManager($this->getProcessorManager($container)); |
|
77 | 2 | return $this->handlerManager; |
|
78 | } |
||
79 | |||
80 | 3 | public function getFormatterManager(ContainerInterface $container) |
|
91 | |||
92 | 3 | public function getProcessorManager(ContainerInterface $container) |
|
103 | } |
||
104 |