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
1 change: 0 additions & 1 deletion src/CacheBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function build(ContainerBuilder $container)

$container->addCompilerPass(new Compiler\SessionSupportCompilerPass());
$container->addCompilerPass(new Compiler\DoctrineSupportCompilerPass());
$container->addCompilerPass(new Compiler\RouterCompilerPass());

if ($container->getParameter('kernel.debug')) {
$container->addCompilerPass(new Compiler\DataCollectorCompilerPass());
Expand Down
22 changes: 15 additions & 7 deletions src/DependencyInjection/CacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@

namespace Cache\CacheBundle\DependencyInjection;

use Cache\CacheBundle\Cache\LoggingCachePool;
use Cache\CacheBundle\DataCollector\CacheDataCollector;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;


/**
* Class CacheExtension
*
* @author Aaron Scherer <[email protected]>
* @author Tobias Nyholm <[email protected]>
*/
class CacheExtension extends Extension
{
Expand All @@ -34,17 +35,24 @@ public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);

if ($container->getParameter('kernel.debug')) {
$container->register('data_collector.cache', CacheDataCollector::class)
->addTag('data_collector', ['template' => CacheDataCollector::TEMPLATE, 'id' => 'cache']);
}
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

foreach (['router', 'session', 'doctrine'] as $section) {
if ($config[$section]['enabled']) {
$container->setParameter('cache.'.$section, $config[$section]);
}
}

if ($config['router']['enabled']) {
$container->getDefinition('cache.router_listener')->replaceArgument(0, new Reference($config['router']['service_id']));
} else {
$container->removeDefinition('cache.router_listener');
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe consider using a services.xml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

if (!$container->getParameter('kernel.debug')) {
$container->removeDefinition('data_collector.cache');
}
}

public function getAlias()
Expand Down
45 changes: 0 additions & 45 deletions src/DependencyInjection/Compiler/RouterCompilerPass.php

This file was deleted.

5 changes: 1 addition & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ private function addRouterSection()
->defaultFalse()
->end()
->integerNode('ttl')
->defaultValue(86400)
->end()
->booleanNode('auto-register')
->defaultTrue()
->defaultValue(604800)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a week a good default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

->end()
->scalarNode('service_id')
->isRequired()
Expand Down
12 changes: 12 additions & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
data_collector.cache:
class: Cache\CacheBundle\DataCollector\CacheDataCollector
tags:
- { name: data_collectorr, template: 'CacheBundle:Collector:cache.html.twig', id: 'cache' }

cache.router_listener:
class: Cache\CacheBundle\Routing\RouterListener
arguments: [~, %cache.router.ttl%]
tags:
- { name: kernel.event_listener, event: kernel.request, method: onBeforeRouting, priority: 33 }
- { name: kernel.event_listener, event: kernel.request, method: onAfterRouting, priority: 31 }
78 changes: 0 additions & 78 deletions src/Routing/Matcher/CacheUrlMatcher.php

This file was deleted.

109 changes: 0 additions & 109 deletions src/Routing/Router.php

This file was deleted.

Loading