Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/CacheBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new Compiler\CacheTaggingPass());
$container->addCompilerPass(new Compiler\SessionSupportCompilerPass());
$container->addCompilerPass(new Compiler\DoctrineCompilerPass());

if ($container->getParameter('kernel.debug')) {
$container->addCompilerPass(new Compiler\DataCollectorCompilerPass());
}
$container->addCompilerPass(new Compiler\LoggerPass());
$container->addCompilerPass(new Compiler\DataCollectorCompilerPass());
}
}
4 changes: 3 additions & 1 deletion src/DataCollector/CacheProxyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

namespace Cache\CacheBundle\DataCollector;

use Psr\Cache\CacheItemPoolInterface;

/**
* An interface for a cache proxy. A cache proxy is created when we profile a cache pool.
*
* @author Tobias Nyholm <[email protected]>
*/
interface CacheProxyInterface
interface CacheProxyInterface extends CacheItemPoolInterface
{
public function __getCalls();

Expand Down
2 changes: 1 addition & 1 deletion src/DataCollector/DecoratingFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(ProxyFactory $proxyFactory)
/**
* @param CacheItemPoolInterface $originalObject original class
*
* @return CacheProxyInterface|CacheItemPoolInterface
* @return CacheProxyInterface
*/
public function create($originalObject)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/CacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function load(array $configs, ContainerBuilder $container)

$this->registerServices($container, $config);

// Add toolbar and data collector if we are debuging
// Add toolbar and data collector if we are debugging
if (!isset($config['data_collector']['enabled'])) {
$config['data_collector']['enabled'] = $container->getParameter('kernel.debug');
}
Expand Down
51 changes: 51 additions & 0 deletions src/DependencyInjection/Compiler/LoggerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of php-cache\cache-bundle package.
*
* (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Cache\CacheBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Add logging to pool implementing LoggerAwareInterface.
*
* @author Tobias Nyholm <[email protected]>
*/
class LoggerPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
*
* @throws \Exception
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasParameter('cache.logging')) {
return;
}

$config = $container->getParameter('cache.logging');
if (!$config['enabled']) {
return;
}

$serviceIds = $container->findTaggedServiceIds('cache.provider');

foreach (array_keys($serviceIds) as $id) {
$poolDefinition = $container->getDefinition($id);
if (!method_exists($poolDefinition->getClass(), 'setLogger')) {
continue;
}
$poolDefinition->addMethodCall('setLogger', [new Reference($config['logger'])]);
}
}
}
1 change: 0 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ private function addLoggingSection()
->addDefaultsIfNotSet()
->children()
->scalarNode('logger')->defaultValue('logger')->end()
->scalarNode('level')->defaultValue('info')->end()
->end();

return $node;
Expand Down