public function load(array $configs, ContainerBuilder $container)
{
if (!$container->getParameter('kernel.debug')) {
return;
}
$definition = new Definition('Joli\\GifExceptionBundle\\EventListener\\ReplaceImageListener');
$definition->addTag('kernel.event_listener', array('event' => KernelEvents::RESPONSE, 'priority' => -1000));
$gifs = array();
$pattern = __DIR__ . '/../Resources/public/images/*/*.gif';
foreach (glob($pattern) as $path) {
$gifs[basename(dirname($path))][] = basename($path);
}
$pattern = __DIR__ . '/../Resources/public/images/other/*.gif';
foreach (glob($pattern) as $path) {
$gifs['other'][] = basename($path);
}
// Set first argument. Next ones will be added by the compiler pass.
$definition->addArgument($gifs);
$container->setDefinition('gif_exception.listener.replace_image', $definition);
}