diff --git a/DependencyInjection/CompilerPass/SymfonyProfilerPass.php b/DependencyInjection/CompilerPass/SymfonyProfilerPass.php index 5bf322a8..9b373e6c 100644 --- a/DependencyInjection/CompilerPass/SymfonyProfilerPass.php +++ b/DependencyInjection/CompilerPass/SymfonyProfilerPass.php @@ -30,7 +30,8 @@ public function process(ContainerBuilder $container) } if (!$container->hasDefinition('translator.data_collector')) { - throw new \LogicException('[PHP-Translation] To integrate with the Symfony profiler you first need to enable it. Please set framework.translator.enabled: true'); + // No Symfony translation data collector was found. We cannot use our collection without it. + $container->removeDefinition('php_translation.data_collector'); } } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index a941c467..a2113db6 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -41,6 +41,7 @@ public function getConfigTreeBuilder() $this->addEditInPlaceNode($root); $this->addWebUINode($root); + $debug = $this->container->getParameter('kernel.debug'); $root ->children() ->arrayNode('locales') @@ -48,7 +49,22 @@ public function getConfigTreeBuilder() ->end() ->scalarNode('default_locale')->info('Your default language or fallback locale. Default will be kernel.default_locale')->end() ->arrayNode('symfony_profiler') - ->canBeEnabled() + ->addDefaultsIfNotSet() + ->treatFalseLike(['enabled' => false]) + ->treatTrueLike(['enabled' => true]) + ->treatNullLike(['enabled' => $debug]) + ->info('Extend the debug profiler with information about requests.') + ->children() + ->booleanNode('enabled') + ->info('Turn the symfony profiler integration on or off. Defaults to kernel debug mode.') + ->defaultValue($debug) + ->end() + ->scalarNode('formatter')->defaultNull()->end() + ->integerNode('captured_body_length') + ->defaultValue(0) + ->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).') + ->end() + ->end() ->children() ->booleanNode('allow_edit')->defaultTrue()->end() ->end() diff --git a/Tests/Unit/DependencyInjection/TranslationExtensionTest.php b/Tests/Unit/DependencyInjection/TranslationExtensionTest.php index 4dd81b7d..12df1d09 100644 --- a/Tests/Unit/DependencyInjection/TranslationExtensionTest.php +++ b/Tests/Unit/DependencyInjection/TranslationExtensionTest.php @@ -24,6 +24,7 @@ protected function getContainerExtensions() { $this->setParameter('kernel.default_locale', 'ar'); $this->setParameter('kernel.root_dir', __DIR__); + $this->setParameter('kernel.debug', true); return [ new TranslationExtension(), diff --git a/composer.json b/composer.json index 9aaf71fc..590c55d1 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,7 @@ "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" }, "minimum-stability": "dev", + "prefer-stable": true, "extra": { "branch-alias": { "dev-master": "0.4-dev"