From 20b5d245c79a53c74827a7cc8d7b14394752d8e8 Mon Sep 17 00:00:00 2001 From: Harm van Tilborg Date: Thu, 11 Jun 2020 09:49:10 +0200 Subject: [PATCH] [FrameworkBundle] Move profiling configuration to PHP --- .../FrameworkExtension.php | 6 +-- .../Resources/config/profiling.php | 38 +++++++++++++++++++ .../Resources/config/profiling.xml | 29 -------------- 3 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index f672e57a88..30865cd206 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -369,7 +369,7 @@ class FrameworkExtension extends Extension $this->registerSsiConfiguration($config['ssi'], $container, $loader); $this->registerFragmentsConfiguration($config['fragments'], $container, $loader); $this->registerTranslatorConfiguration($config['translator'], $container, $loader, $config['default_locale']); - $this->registerProfilerConfiguration($config['profiler'], $container, $loader); + $this->registerProfilerConfiguration($config['profiler'], $container, $loader, $phpLoader); $this->registerWorkflowConfiguration($config['workflows'], $container, $loader); $this->registerDebugConfiguration($config['php_errors'], $container, $phpLoader); $this->registerRouterConfiguration($config['router'], $container, $loader, $config['translator']['enabled_locales'] ?? []); @@ -568,7 +568,7 @@ class FrameworkExtension extends Extension $container->setParameter('fragment.path', $config['path']); } - private function registerProfilerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) + private function registerProfilerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader, PhpFileLoader $phpLoader) { if (!$this->isConfigEnabled($container, $config)) { // this is needed for the WebProfiler to work even if the profiler is disabled @@ -577,7 +577,7 @@ class FrameworkExtension extends Extension return; } - $loader->load('profiling.xml'); + $phpLoader->load('profiling.php'); $loader->load('collectors.xml'); $loader->load('cache_debug.xml'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php new file mode 100644 index 0000000000..68a09c9f5f --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Loader\Configurator; + +use Symfony\Component\HttpKernel\EventListener\ProfilerListener; +use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage; +use Symfony\Component\HttpKernel\Profiler\Profiler; + +return static function (ContainerConfigurator $container) { + $container->services() + ->set('profiler', Profiler::class) + ->public() + ->args([service('profiler.storage'), service('logger')->nullOnInvalid()]) + ->tag('monolog.logger', ['channel' => 'profiler']) + + ->set('profiler.storage', FileProfilerStorage::class) + ->args([param('profiler.storage.dsn')]) + + ->set('profiler_listener', ProfilerListener::class) + ->args([ + service('profiler'), + service('request_stack'), + null, + param('profiler_listener.only_exceptions'), + param('profiler_listener.only_master_requests'), + ]) + ->tag('kernel.event_subscriber') + ; +}; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml deleted file mode 100644 index 166be86b2e..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/profiling.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - %profiler.storage.dsn% - - - - - - - null - %profiler_listener.only_exceptions% - %profiler_listener.only_master_requests% - - -