1 | <?php |
||
37 | class SQLLoggerCollectorFactory implements FactoryInterface |
||
38 | { |
||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $name; |
||
43 | |||
44 | /** |
||
45 | * @param string $name |
||
46 | */ |
||
47 | 5 | public function __construct($name) |
|
48 | { |
||
49 | 5 | $this->name = $name; |
|
50 | 5 | } |
|
51 | |||
52 | /** |
||
53 | * {@inheritDoc} |
||
54 | */ |
||
55 | 5 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
56 | { |
||
57 | /** @var $options \DoctrineORMModule\Options\SQLLoggerCollectorOptions */ |
||
58 | 5 | $options = $this->getOptions($container); |
|
59 | |||
60 | // @todo always ask the serviceLocator instead? (add a factory?) |
||
61 | 5 | if ($options->getSqlLogger()) { |
|
62 | 2 | $debugStackLogger = $container->get($options->getSqlLogger()); |
|
63 | 2 | } else { |
|
64 | 3 | $debugStackLogger = new DebugStack(); |
|
65 | } |
||
66 | |||
67 | /* @var $configuration \Doctrine\ORM\Configuration */ |
||
68 | 5 | $configuration = $container->get($options->getConfiguration()); |
|
69 | |||
70 | 5 | if (null !== $configuration->getSQLLogger()) { |
|
71 | 1 | $logger = new LoggerChain(); |
|
72 | 1 | $logger->addLogger($debugStackLogger); |
|
73 | 1 | $logger->addLogger($configuration->getSQLLogger()); |
|
74 | 1 | $configuration->setSQLLogger($logger); |
|
75 | 1 | } else { |
|
76 | 4 | $configuration->setSQLLogger($debugStackLogger); |
|
77 | } |
||
78 | |||
79 | 5 | return new SQLLoggerCollector($debugStackLogger, 'doctrine.sql_logger_collector.' . $options->getName()); |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * {@inheritDoc} |
||
84 | */ |
||
85 | 5 | public function createService(ServiceLocatorInterface $container) |
|
89 | |||
90 | /** |
||
91 | * @param ContainerInterface $serviceLocator |
||
92 | * @return mixed |
||
93 | * @throws RuntimeException |
||
94 | */ |
||
95 | 5 | protected function getOptions(ContainerInterface $serviceLocator) |
|
116 | |||
117 | /** |
||
118 | * {@inheritDoc} |
||
119 | */ |
||
120 | 5 | protected function getOptionsClass() |
|
124 | } |
||
125 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.