From bdcf6ea57d3fbdd9e491cd9208864cd8c3648d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20R?= Date: Fri, 10 May 2019 13:55:00 +0200 Subject: [PATCH] EZP-30402: Make Dashboard code more solid when it comes to detecting trial or not (#36) * EZP-30402: Make Dashboard code more solid when it comes to detecting trial or not Adds logic to also read info from composer.json to detect if packages are pulled from ttl channel or not. Besides the current issues with updates.ez.no telling composer the packages are ttl when they are not (diff between packages.json and composer.json). This also solves issues when people switch from TTL to BUL, and install won't show they have switched until all TTL paclages actually have a new release to pull in. * Fix CS * [Travis] Drop PHP 5.6 and 7.0 for 1.0 to align with composer.json * Update SystemInfo/Exception/ComposerJsonFileNotFoundException.php Co-Authored-By: Mikolaj Adamczyk * Type hints * Apply suggestions from code review Co-Authored-By: Gunnstein Lye --- .travis.yml | 2 - AdminUi/Component/EzInfoTwigComponent.php | 2 +- Resources/config/services.yml | 3 +- .../themes/admin/dashboard/block/ez.html.twig | 2 +- .../Collector/EzSystemInfoCollector.php | 8 +- .../JsonComposerLockSystemInfoCollector.php | 69 ++++++-- .../ComposerJsonFileNotFoundException.php | 20 +++ .../ComposerLockFileNotFoundException.php | 2 +- SystemInfo/Value/ComposerSystemInfo.php | 9 ++ ...sonComposerLockSystemInfoCollectorTest.php | 19 ++- .../Collector/_fixtures/composer.json | 147 ++++++++++++++++++ 11 files changed, 259 insertions(+), 24 deletions(-) create mode 100644 SystemInfo/Exception/ComposerJsonFileNotFoundException.php create mode 100644 Tests/SystemInfo/Collector/_fixtures/composer.json diff --git a/.travis.yml b/.travis.yml index 2fc452f2..3977fb81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ cache: matrix: fast_finish: true include: - - php: 5.6 - - php: 7.0 - php: 7.1 env: CHECK_CS=true - php: 7.2 diff --git a/AdminUi/Component/EzInfoTwigComponent.php b/AdminUi/Component/EzInfoTwigComponent.php index 9b465f92..f2452376 100644 --- a/AdminUi/Component/EzInfoTwigComponent.php +++ b/AdminUi/Component/EzInfoTwigComponent.php @@ -73,7 +73,7 @@ private function replaceUrlPlaceholders(): array $urls = $this->urlList; foreach ($this->urlList as $urlName => $url) { foreach ($this->ezSystemInfo as $attribute => $value) { - if (is_string($value) && strpos($url,'{ez.' . $attribute . '}') !== false) { + if (\is_string($value) && strpos($url, '{ez.' . $attribute . '}') !== false) { $urls[$urlName] = str_replace('{ez.' . $attribute . '}', $value, $url); } } diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 5d2f1582..463c3ed0 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -55,13 +55,14 @@ services: - "@support_tools.system_info.collector.composer.lock_file" - "%kernel.debug%" # Can't tag this before v0.3 (2.5?) as it will blow up in admin UI for missing templates there - # And it does not look like there is anway to add it from this package, so maybe it needs to be made extensible(?) + # And it does not look like there is any way to add it from this package, so maybe it needs to be made extensible(?) #tags: [{ name: "support_tools.system_info.collector", identifier: "ez" }] support_tools.system_info.collector.composer.lock_file: class: "%support_tools.system_info.collector.composer.lock_file.class%" arguments: - "%kernel.root_dir%/../composer.lock" + - "%kernel.root_dir%/../composer.json" tags: - { name: "support_tools.system_info.collector", identifier: "composer" } diff --git a/Resources/views/themes/admin/dashboard/block/ez.html.twig b/Resources/views/themes/admin/dashboard/block/ez.html.twig index 70f275f3..dc5145bb 100644 --- a/Resources/views/themes/admin/dashboard/block/ez.html.twig +++ b/Resources/views/themes/admin/dashboard/block/ez.html.twig @@ -11,7 +11,7 @@ {% set levels = {0: "info", 1: "warning", 2: "danger"} %} {% set icons = {0: "", 1: "⚠", 2: "⚠"} %} {% set status %} - {% spaceless %} +{% spaceless %} {% if not ez.release %} {% set severity = 1 %}