-
Notifications
You must be signed in to change notification settings - Fork 16
Added a router listener #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1b12389
fb54b41
218e080
2b25a7c
15e22ac
e078954
4a6899e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
{ | ||
|
@@ -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'); | ||
} | ||
|
||
if (!$container->getParameter('kernel.debug')) { | ||
$container->removeDefinition('data_collector.cache'); | ||
} | ||
} | ||
|
||
public function getAlias() | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,10 +142,7 @@ private function addRouterSection() | |
->defaultFalse() | ||
->end() | ||
->integerNode('ttl') | ||
->defaultValue(86400) | ||
->end() | ||
->booleanNode('auto-register') | ||
->defaultTrue() | ||
->defaultValue(604800) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is a week a good default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah |
||
->end() | ||
->scalarNode('service_id') | ||
->isRequired() | ||
|
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 } |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah