From f5c355e1ba399a1b3512367647d902148bdaf09f Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sun, 21 Oct 2018 10:31:42 +0200 Subject: [PATCH] [WebProfilerBundle] Remove application name --- UPGRADE-4.2.md | 9 ++ UPGRADE-5.0.md | 3 + .../Resources/config/collectors.xml | 6 - .../views/Collector/config.html.twig | 133 +++++++----------- src/Symfony/Component/HttpKernel/CHANGELOG.md | 3 + .../DataCollector/ConfigDataCollector.php | 21 ++- .../DataCollector/ConfigDataCollectorTest.php | 21 ++- 7 files changed, 95 insertions(+), 101 deletions(-) diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md index 4eebf8668c..4b1c481569 100644 --- a/UPGRADE-4.2.md +++ b/UPGRADE-4.2.md @@ -111,6 +111,15 @@ HttpFoundation will respectively change from "false" to "null" and from "null" to "lax" in Symfony 5.0, you should define their values explicitly or use "Cookie::create()" instead. +HttpKernel +---------- + + * The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been deprecated + * The `KernelInterface::getName()` and the `kernel.name` parameter have been deprecated + * Deprecated the first and second constructor argument of `ConfigDataCollector` + * Deprecated `ConfigDataCollector::getApplicationName()` + * Deprecated `ConfigDataCollector::getApplicationVersion()` + FrameworkBundle --------------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 1993a37552..59863eb8cc 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -182,6 +182,9 @@ HttpKernel * The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been removed * The `KernelInterface::getName()` and the `kernel.name` parameter have been removed + * Removed the first and second constructor argument of `ConfigDataCollector` + * Removed `ConfigDataCollector::getApplicationName()` + * Removed `ConfigDataCollector::getApplicationVersion()` Monolog ------- diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml index 59fe4ef7d6..93005e07ac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml @@ -10,12 +10,6 @@ - - - - %kernel.project_dir% - - diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 2a8c6b071a..3c4135db3c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -19,26 +19,14 @@ {% endif %} {% set icon %} - {% if collector.applicationname %} - {{ collector.applicationname }} - {{ collector.applicationversion }} - {% elseif collector.symfonyState is defined %} - - {{ include('@WebProfiler/Icon/symfony.svg') }} - - {{ collector.symfonyversion }} - {% endif %} + + {{ include('@WebProfiler/Icon/symfony.svg') }} + + {{ collector.symfonyState is defined ? collector.symfonyversion : 'n/a' }} {% endset %} {% set text %}
- {% if collector.applicationname %} -
- {{ collector.applicationname }} - {{ collector.applicationversion }} -
- {% endif %} -
Profiler token @@ -92,15 +80,9 @@
Resources - {% if 'Silex' == collector.applicationname %} - - Read Silex Docs - - {% else %} - - Read Symfony {{ collector.symfonyversion }} Docs - - {% endif %} + + Read Symfony {{ collector.symfonyversion }} Docs +
@@ -126,74 +108,53 @@ {% endblock %} {% block panel %} - {% if collector.applicationname %} - {# this application is not the Symfony framework #} -

Project Configuration

+

Symfony Configuration

-
-
- {{ collector.applicationname }} - Application name -
- -
- {{ collector.applicationversion }} - Application version -
+
+
+ {{ collector.symfonyversion }} + Symfony version
-

- Based on Symfony {{ collector.symfonyversion }} -

- {% else %} -

Symfony Configuration

- -
+ {% if 'n/a' != collector.env %}
- {{ collector.symfonyversion }} - Symfony version + {{ collector.env }} + Environment
+ {% endif %} - {% if 'n/a' != collector.env %} -
- {{ collector.env }} - Environment -
- {% endif %} + {% if 'n/a' != collector.debug %} +
+ {{ collector.debug ? 'enabled' : 'disabled' }} + Debug +
+ {% endif %} +
- {% if 'n/a' != collector.debug %} -
- {{ collector.debug ? 'enabled' : 'disabled' }} - Debug -
- {% endif %} -
- - {% set symfony_status = { dev: 'Unstable Version', stable: 'Stable Version', eom: 'Maintenance Ended', eol: 'Version Expired' } %} - {% set symfony_status_class = { dev: 'warning', stable: 'success', eom: 'warning', eol: 'error' } %} - - - - - - - - - - - - - - - - - -
Symfony StatusBugs {{ collector.symfonystate in ['eom', 'eol'] ? 'were' : 'are' }} fixed untilSecurity issues {{ collector.symfonystate == 'eol' ? 'were' : 'are' }} fixed until
- {{ symfony_status[collector.symfonystate]|upper }} - {{ collector.symfonyeom }}{{ collector.symfonyeol }} - View roadmap -
- {% endif %} + {% set symfony_status = { dev: 'Unstable Version', stable: 'Stable Version', eom: 'Maintenance Ended', eol: 'Version Expired' } %} + {% set symfony_status_class = { dev: 'warning', stable: 'success', eom: 'warning', eol: 'error' } %} + + + + + + + + + + + + + + + + + +
Symfony StatusBugs {{ collector.symfonystate in ['eom', 'eol'] ? 'were' : 'are' }} fixed untilSecurity issues {{ collector.symfonystate == 'eol' ? 'were' : 'are' }} fixed until
+ {{ symfony_status[collector.symfonystate]|upper }} + {{ collector.symfonyeom }}{{ collector.symfonyeol }} + View roadmap +

PHP Configuration

diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index 476f7843e8..8ba132f6c4 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -6,6 +6,9 @@ CHANGELOG * deprecated `KernelInterface::getRootDir()` and the `kernel.root_dir` parameter * deprecated `KernelInterface::getName()` and the `kernel.name` parameter + * deprecated the first and second constructor argument of `ConfigDataCollector` + * deprecated `ConfigDataCollector::getApplicationName()` + * deprecated `ConfigDataCollector::getApplicationVersion()` 4.1.0 ----- diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 14b4b48004..1d5aad221f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -30,12 +30,15 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte private $version; private $hasVarDumper; - /** - * @param string $name The name of the application using the web profiler - * @param string $version The version of the application using the web profiler - */ public function __construct(string $name = null, string $version = null) { + if (1 <= \func_num_args()) { + @trigger_error(sprintf('The "$name" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + } + if (2 <= \func_num_args()) { + @trigger_error(sprintf('The "$version" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + } + $this->name = $name; $this->version = $version; $this->hasVarDumper = class_exists(LinkStub::class); @@ -105,13 +108,23 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte $this->data = $this->cloneVar($this->data); } + /** + * @deprecated since Symfony 4.2 + */ public function getApplicationName() { + @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + return $this->data['app_name']; } + /** + * @deprecated since Symfony 4.2 + */ public function getApplicationVersion() { + @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + return $this->data['app_version']; } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 4d40560792..800f682663 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -41,15 +41,26 @@ class ConfigDataCollectorTest extends TestCase $this->assertSame(\extension_loaded('Zend OPcache') && ini_get('opcache.enable'), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && ini_get('apc.enabled'), $c->hasApcu()); } + + /** + * @group legacy + * @expectedDeprecation The "$name" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2. + * @expectedDeprecation The "$version" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2. + * @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationName()" is deprecated since Symfony 4.2. + * @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationVersion()" is deprecated since Symfony 4.2. + */ + public function testLegacy() + { + $c = new ConfigDataCollector('name', null); + $c->collect(new Request(), new Response()); + + $this->assertSame('name', $c->getApplicationName()); + $this->assertNull($c->getApplicationVersion()); + } } class KernelForTest extends Kernel { - public function getName() - { - return 'testkernel'; - } - public function registerBundles() { }