Skip to content

Commit 7bde891

Browse files
authored
Do not throw exception when SF Translation collector is not found. (#108)
* Symfony profiler integration default value changed to "same as debug mode". We do not longer throw exception when Symfony Translation collector was not found. * Fixed broken tests
1 parent af32540 commit 7bde891

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

DependencyInjection/CompilerPass/SymfonyProfilerPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public function process(ContainerBuilder $container)
3030
}
3131

3232
if (!$container->hasDefinition('translator.data_collector')) {
33-
throw new \LogicException('[PHP-Translation] To integrate with the Symfony profiler you first need to enable it. Please set framework.translator.enabled: true');
33+
// No Symfony translation data collector was found. We cannot use our collection without it.
34+
$container->removeDefinition('php_translation.data_collector');
3435
}
3536
}
3637
}

DependencyInjection/Configuration.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,30 @@ public function getConfigTreeBuilder()
4141
$this->addEditInPlaceNode($root);
4242
$this->addWebUINode($root);
4343

44+
$debug = $this->container->getParameter('kernel.debug');
4445
$root
4546
->children()
4647
->arrayNode('locales')
4748
->prototype('scalar')->end()
4849
->end()
4950
->scalarNode('default_locale')->info('Your default language or fallback locale. Default will be kernel.default_locale')->end()
5051
->arrayNode('symfony_profiler')
51-
->canBeEnabled()
52+
->addDefaultsIfNotSet()
53+
->treatFalseLike(['enabled' => false])
54+
->treatTrueLike(['enabled' => true])
55+
->treatNullLike(['enabled' => $debug])
56+
->info('Extend the debug profiler with information about requests.')
57+
->children()
58+
->booleanNode('enabled')
59+
->info('Turn the symfony profiler integration on or off. Defaults to kernel debug mode.')
60+
->defaultValue($debug)
61+
->end()
62+
->scalarNode('formatter')->defaultNull()->end()
63+
->integerNode('captured_body_length')
64+
->defaultValue(0)
65+
->info('Limit long HTTP message bodies to x characters. If set to 0 we do not read the message body. Only available with the default formatter (FullHttpMessageFormatter).')
66+
->end()
67+
->end()
5268
->children()
5369
->booleanNode('allow_edit')->defaultTrue()->end()
5470
->end()

Tests/Unit/DependencyInjection/TranslationExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ protected function getContainerExtensions()
2424
{
2525
$this->setParameter('kernel.default_locale', 'ar');
2626
$this->setParameter('kernel.root_dir', __DIR__);
27+
$this->setParameter('kernel.debug', true);
2728

2829
return [
2930
new TranslationExtension(),

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
4949
},
5050
"minimum-stability": "dev",
51+
"prefer-stable": true,
5152
"extra": {
5253
"branch-alias": {
5354
"dev-master": "0.4-dev"

0 commit comments

Comments
 (0)