Skip to content

Commit f840302

Browse files
committed
Remove randomness from container compilation.
1 parent e60b013 commit f840302

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

DependencyInjection/MonologExtension.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,46 +184,40 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
184184

185185
case 'gelf':
186186
if (isset($handler['publisher']['id'])) {
187-
$publisherId = $handler['publisher']['id'];
187+
$publisher = new Reference($handler['publisher']['id']);
188188
} elseif (class_exists('Gelf\Transport\UdpTransport')) {
189189
$transport = new Definition("Gelf\Transport\UdpTransport", array(
190190
$handler['publisher']['hostname'],
191191
$handler['publisher']['port'],
192192
$handler['publisher']['chunk_size'],
193193
));
194-
$transportId = uniqid('monolog.gelf.transport.', true);
195194
$transport->setPublic(false);
196-
$container->setDefinition($transportId, $transport);
197195

198196
$publisher = new Definition('Gelf\Publisher', array());
199-
$publisher->addMethodCall('addTransport', array(new Reference($transportId)));
200-
$publisherId = uniqid('monolog.gelf.publisher.', true);
197+
$publisher->addMethodCall('addTransport', array($transport));
201198
$publisher->setPublic(false);
202-
$container->setDefinition($publisherId, $publisher);
203199
} elseif (class_exists('Gelf\MessagePublisher')) {
204200
$publisher = new Definition('Gelf\MessagePublisher', array(
205201
$handler['publisher']['hostname'],
206202
$handler['publisher']['port'],
207203
$handler['publisher']['chunk_size'],
208204
));
209205

210-
$publisherId = uniqid('monolog.gelf.publisher.', true);
211206
$publisher->setPublic(false);
212-
$container->setDefinition($publisherId, $publisher);
213207
} else {
214208
throw new \RuntimeException('The gelf handler requires the graylog2/gelf-php package to be installed');
215209
}
216210

217211
$definition->setArguments(array(
218-
new Reference($publisherId),
212+
$publisher,
219213
$handler['level'],
220214
$handler['bubble'],
221215
));
222216
break;
223217

224218
case 'mongo':
225219
if (isset($handler['mongo']['id'])) {
226-
$clientId = $handler['mongo']['id'];
220+
$client = new Reference($handler['mongo']['id']);
227221
} else {
228222
$server = 'mongodb://';
229223

@@ -237,13 +231,11 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
237231
$server,
238232
));
239233

240-
$clientId = uniqid('monolog.mongo.client.', true);
241234
$client->setPublic(false);
242-
$container->setDefinition($clientId, $client);
243235
}
244236

245237
$definition->setArguments(array(
246-
new Reference($clientId),
238+
$client,
247239
$handler['mongo']['database'],
248240
$handler['mongo']['collection'],
249241
$handler['level'],
@@ -253,7 +245,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
253245

254246
case 'elasticsearch':
255247
if (isset($handler['elasticsearch']['id'])) {
256-
$clientId = $handler['elasticsearch']['id'];
248+
$elasticaClient = new Reference($handler['elasticsearch']['id']);
257249
} else {
258250
// elastica client new definition
259251
$elasticaClient = new Definition('Elastica\Client');
@@ -278,14 +270,12 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
278270
$elasticaClientArguments
279271
));
280272

281-
$clientId = uniqid('monolog.elastica.client.', true);
282273
$elasticaClient->setPublic(false);
283-
$container->setDefinition($clientId, $elasticaClient);
284274
}
285275

286276
// elastica handler definition
287277
$definition->setArguments(array(
288-
new Reference($clientId),
278+
$elasticaClient,
289279
array(
290280
'index' => $handler['index'],
291281
'type' => $handler['document_type'],

0 commit comments

Comments
 (0)