Skip to content

Commit

Permalink
Reimplementation of the RedisProfilerStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
GijsL committed Nov 3, 2016
1 parent 78ae7e0 commit a21034b
Show file tree
Hide file tree
Showing 7 changed files with 1,004 additions and 0 deletions.
20 changes: 20 additions & 0 deletions DependencyInjection/Configuration/Configuration.php
Expand Up @@ -66,6 +66,7 @@ public function getConfigTreeBuilder()
$this->addDoctrineSection($rootNode);
$this->addMonologSection($rootNode);
$this->addSwiftMailerSection($rootNode);
$this->addProfilerStorageSection($rootNode);

return $treeBuilder;
}
Expand Down Expand Up @@ -242,4 +243,23 @@ private function addSwiftMailerSection(ArrayNodeDefinition $rootNode)
->end()
->end();
}

/**
* Adds the snc_redis.profiler_storage configuration
*
* @param ArrayNodeDefinition $rootNode
*/
private function addProfilerStorageSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('profiler_storage')
->canBeUnset()
->children()
->scalarNode('client')->isRequired()->end()
->scalarNode('ttl')->isRequired()->end()
->end()
->end()
->end();
}
}
23 changes: 23 additions & 0 deletions DependencyInjection/SncRedisExtension.php
Expand Up @@ -68,6 +68,10 @@ public function load(array $configs, ContainerBuilder $container)
if (isset($config['swiftmailer'])) {
$this->loadSwiftMailer($config, $container);
}

if (isset($config['profiler_storage'])) {
$this->loadProfilerStorage($config, $container, $loader);
}
}

/**
Expand Down Expand Up @@ -385,6 +389,25 @@ protected function loadSwiftMailer(array $config, ContainerBuilder $container)
$container->setAlias('swiftmailer.spool.redis', 'snc_redis.swiftmailer.spool');
}

/**
* Loads the profiler storage configuration.
*
* @param array $config A configuration array
* @param ContainerBuilder $container A ContainerBuilder instance
* @param XmlFileLoader $loader A XmlFileLoader instance
*/
protected function loadProfilerStorage(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
$loader->load('profiler_storage.xml');

$container->setParameter('snc_redis.profiler_storage.client', $config['profiler_storage']['client']);
$container->setParameter('snc_redis.profiler_storage.ttl', $config['profiler_storage']['ttl']);

$client = $container->getParameter('snc_redis.profiler_storage.client');
$client = sprintf('snc_redis.%s_client', $client);
$container->setAlias('snc_redis.profiler_storage.client', $client);
}

public function getConfiguration(array $config, ContainerBuilder $container)
{
return new Configuration($container->getParameter('kernel.debug'));
Expand Down

0 comments on commit a21034b

Please sign in to comment.