1 | <?php |
||
21 | class SQLLoggerCollectorFactory implements FactoryInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $name; |
||
27 | |||
28 | /** |
||
29 | * @param string $name |
||
30 | */ |
||
31 | 5 | public function __construct($name) |
|
35 | |||
36 | /** |
||
37 | * {@inheritDoc} |
||
38 | */ |
||
39 | 5 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
40 | { |
||
41 | /** @var $options SQLLoggerCollectorOptions */ |
||
42 | 5 | $options = $this->getOptions($container); |
|
43 | |||
44 | // @todo always ask the serviceLocator instead? (add a factory?) |
||
45 | 5 | if ($options->getSqlLogger()) { |
|
|
|||
46 | 2 | $debugStackLogger = $container->get($options->getSqlLogger()); |
|
47 | } else { |
||
48 | 3 | $debugStackLogger = new DebugStack(); |
|
49 | } |
||
50 | |||
51 | /* @var $configuration \Doctrine\ORM\Configuration */ |
||
52 | 5 | $configuration = $container->get($options->getConfiguration()); |
|
53 | |||
54 | 5 | if (null !== $configuration->getSQLLogger()) { |
|
55 | 1 | $logger = new LoggerChain(); |
|
56 | 1 | $logger->addLogger($debugStackLogger); |
|
57 | 1 | $logger->addLogger($configuration->getSQLLogger()); |
|
58 | 1 | $configuration->setSQLLogger($logger); |
|
59 | } else { |
||
60 | 4 | $configuration->setSQLLogger($debugStackLogger); |
|
61 | } |
||
62 | |||
63 | 5 | return new SQLLoggerCollector($debugStackLogger, 'doctrine.sql_logger_collector.' . $options->getName()); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritDoc} |
||
68 | */ |
||
69 | 5 | public function createService(ServiceLocatorInterface $container) |
|
73 | |||
74 | /** |
||
75 | * @param ContainerInterface $serviceLocator |
||
76 | * @return mixed |
||
77 | * @throws RuntimeException |
||
78 | */ |
||
79 | 5 | protected function getOptions(ContainerInterface $serviceLocator) |
|
98 | |||
99 | /** |
||
100 | * {@inheritDoc} |
||
101 | */ |
||
102 | 5 | protected function getOptionsClass() |
|
106 | } |
||
107 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: