From c47d5a1ae040432f1732ca2f6e6c9f4b4acc89e3 Mon Sep 17 00:00:00 2001 From: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> Date: Tue, 3 Nov 2020 09:48:11 +0100 Subject: [PATCH] EZP-32097: Expose EzSystemInfo in Admin UI and SystemInfoDumpCommand (#69) --- .travis.yml | 98 ++++++++----- .travis/prepare_ezplatform.sh | 15 ++ composer.json | 88 ++++++------ .../Resources/config/default_settings.yaml | 4 + src/bundle/Resources/config/services.yaml | 11 +- src/bundle/Resources/config/view.yaml | 2 +- .../translations/systeminfo.en.xliff | 45 ++++++ .../admin/system_info/my_ibexa.html.twig | 56 ++++++++ .../admin/ui/dashboard/block/ez.html.twig | 4 +- ...ector.php => IbexaSystemInfoCollector.php} | 129 +++++++++++------- .../{EzSystemInfo.php => IbexaSystemInfo.php} | 18 ++- ...t.php => IbexaSystemInfoCollectorTest.php} | 8 +- .../Collector/_fixtures/composer.json | 4 +- .../Dashboard/EzInfoTwigComponent.php | 16 +-- 14 files changed, 342 insertions(+), 156 deletions(-) create mode 100755 .travis/prepare_ezplatform.sh create mode 100644 src/bundle/Resources/views/themes/admin/system_info/my_ibexa.html.twig rename src/bundle/SystemInfo/Collector/{EzSystemInfoCollector.php => IbexaSystemInfoCollector.php} (56%) rename src/bundle/SystemInfo/Value/{EzSystemInfo.php => IbexaSystemInfo.php} (78%) rename src/bundle/Tests/SystemInfo/Collector/{EzSystemInfoCollectorTest.php => IbexaSystemInfoCollectorTest.php} (73%) diff --git a/.travis.yml b/.travis.yml index e635bf31..3a9f2d57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,63 @@ -dist: xenial -sudo: required - -language: php - -cache: - directories: - - $HOME/.composer/cache/files - -matrix: - fast_finish: true - include: - - php: 7.3 - env: CHECK_CS=true - -# test only on matching branches (+ Pull requests) -branches: - only: - - master - - /^\d.\d+$/ - -before_script: - - travis_retry composer selfupdate - # Avoid memory issues on composer install - - phpenv config-rm xdebug.ini - - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - # Install packages - - travis_retry composer install --prefer-dist --no-interaction - -script: - - php vendor/bin/phpunit - - if [ "$CHECK_CS" = "true" ]; then vendor/bin/php-cs-fixer fix -v --dry-run --diff --show-progress=estimating; fi - -notifications: - email: false +dist: xenial +language: php + +cache: + directories: + - $HOME/.composer/cache/files + +matrix: + fast_finish: true + include: + - php: 7.3 + name: "Code style" + env: CHECK_CS=true + - php: 7.3 + name: "Unit tests" + env: UNIT_TESTS=true + - php: 7.3 + name: "System informarion browser tests" + env: + - EZPLATFORM_REPO="https://github.com/ezsystems/ezplatform.git" + - APP_ENV=behat + - APP_DEBUG=1 + - COMPOSE_FILE="doc/docker/base-dev.yml:doc/docker/selenium.yml" + - BEHAT_OPTS="--profile=adminui --suite=adminui --tags=@systemInformation" + +# test only on matching branches (+ Pull requests) +branches: + only: + - master + - /^\d.\d+$/ + +notifications: + slack: + rooms: + - secure: "2f0W8DM1YKXN/AHjSTYKExKxss+XUrSqATrl2yrGr0qJAwTHxVZSfXCgpHqbKk3bSMeS08/xg5hsk4i5H0MBZVcqYNyP6XvKQ+8IlO9KCXrKbw6iK/9iPnG795wDbqyF9Aj0M5CzJ1AP3flR1/fuaq4at1Oyv7g5CUcHn/WigR262ByWuCEiCfJGAYDyEZ35WpE+LBDqVQ1fIhEThRxOnZH4EQpdY7wzKh8Ujo4V0c465OT6mcJ7XWkrJAcc0MVPpUP6Cgov9Nkc4Ahrdsv128LW6Mvb2Cf4wcrm1QUjeqoVcVb3Zm4h4ve4Px3nPP82wYgrDbe/eD2PUU0XRcmqYr7MTxjhieW/Eq6P5lY/peROb3WQrG0WNoFNWKciiNFOBgJ5xJyENMe77dt2ZJ2G/tqZ3/VWBAzmUoAFX0X2EXB3qMfNK1dnBzUrbBaG7C1UQLEvpV7PfHJB8inss+i29844lKxdJTDiilHMFEfyVbjXK/CsQlz7lqzgyGlPvr4iT9WW1x2UuRJlZDS0GRHGWaPZe8S+LRIP0o7k/MKsaIBO+sxm52UDWBwXbRz5FFHV26TG8d7HHvPUa3sXI4xGePcdW1qare4o+92ivmzxMLgQ+LZP2Pro+t+pTchotyeOgO7umZOQXPR5t92afxyewEQ8mpzo+1CDDfxp14tRcn4=" + on_success: change + on_failure: always + on_pull_requests: false + +before_script: + - travis_retry composer selfupdate + # Avoid memory issues on composer install + - phpenv config-rm xdebug.ini + - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + # Install packages + - if [ "${CHECK_CS}" != "" -o "${UNIT_TESTS}" != "" ] ; then travis_retry composer install ; fi + - if [ "${BEHAT_OPTS}" != "" ] ; then ./.travis/prepare_ezplatform.sh; fi + +script: + - if [ "${UNIT_TESTS}" != "" ] ; then php vendor/bin/phpunit ; fi + - if [ "$CHECK_CS" = "true" ]; then vendor/bin/php-cs-fixer fix -v --dry-run --diff --show-progress=estimating; fi + - if [ "${BEHAT_OPTS}" != "" ] ; then cd "$HOME/build/ezplatform"; docker-compose exec --user www-data app sh -c "bin/ezbehat ${BEHAT_OPTS}" ; fi + +after_failure: + # Will show us the last bit of the log of container's main processes + # (not counting shell process above running php and behat) + # NOTE: errors during docker setup of travis build won't show up here (can't output all as it is too much in debug/verbose mode) + - docker-compose logs -t --tail=15 + # Will show us what is up, and how long it's been up + - docker ps -s + +after_script: + - if [ "${BEHAT_OPTS}" != "" ] ; then bin/ezreport ; fi diff --git a/.travis/prepare_ezplatform.sh b/.travis/prepare_ezplatform.sh new file mode 100755 index 00000000..f0b81ed8 --- /dev/null +++ b/.travis/prepare_ezplatform.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +EZPLATFORM_BRANCH=`php -r 'echo json_decode(file_get_contents("./composer.json"))->extra->_ezplatform_branch_for_behat_tests;'` +EZPLATFORM_BRANCH="${EZPLATFORM_BRANCH:-master}" +PACKAGE_BUILD_DIR=$PWD +EZPLATFORM_BUILD_DIR=${HOME}/build/ezplatform + +echo "> Cloning ezsystems/ezplatform:${EZPLATFORM_BRANCH}" +git clone --depth 1 --single-branch --branch "${EZPLATFORM_BRANCH}" ${EZPLATFORM_REPO} ${EZPLATFORM_BUILD_DIR} +cd ${EZPLATFORM_BUILD_DIR} + +# Copy over auth.json +cp $TRAVIS_BUILD_DIR/auth.json . + +/bin/bash ./bin/.travis/trusty/setup_ezplatform.sh "${COMPOSE_FILE}" '' "${PACKAGE_BUILD_DIR}" diff --git a/composer.json b/composer.json index 64ceab48..e6789d7d 100644 --- a/composer.json +++ b/composer.json @@ -1,43 +1,45 @@ -{ - "name": "ezsystems/ez-support-tools", - "description": "Providing information about the system eZ Platform/Enterprise/Commerce is running on, and eZ install itself", - "license": "GPL-2.0", - "type": "ezplatform-bundle", - "authors": [ - { - "name": "eZ Systems", - "email": "dev-team@ez.no" - } - ], - "require": { - "php": "^7.3", - "ezsystems/ezplatform-kernel": "~1.2.0@dev", - "ezsystems/ezplatform-core": "^2.1@dev", - "ezsystems/ezplatform-admin-ui": "^2.2@dev", - "ocramius/proxy-manager": "^2.2", - "symfony/proxy-manager-bridge": "^5.0", - "zetacomponents/system-information": "^1.1.1", - "doctrine/inflector": "^1.3" - }, - "require-dev": { - "ezsystems/ezplatform-code-style": "^0.1", - "friendsofphp/php-cs-fixer": "^2.16", - "ezsystems/doctrine-dbal-schema": "^1.0@dev", - "phpunit/phpunit": "^8.2", - "matthiasnoback/symfony-dependency-injection-test": "^4.0" - }, - "autoload": { - "psr-4": { - "EzSystems\\EzSupportToolsBundle\\": "src/bundle/", - "EzSystems\\EzSupportTools\\": "src/lib/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "scripts": { - "fix-cs": "@php ./vendor/bin/php-cs-fixer fix -v --show-progress=estimating" - } -} +{ + "name": "ezsystems/ez-support-tools", + "description": "Providing information about the system eZ Platform/Enterprise/Commerce is running on, and eZ install itself", + "license": "GPL-2.0", + "type": "ezplatform-bundle", + "authors": [ + { + "name": "eZ Systems", + "email": "dev-team@ez.no" + } + ], + "require": { + "php": "^7.3", + "ezsystems/ezplatform-kernel": "~1.2.0@dev", + "ezsystems/ezplatform-core": "^2.1@dev", + "ezsystems/ezplatform-admin-ui": "^2.2@dev", + "ocramius/proxy-manager": "^2.2", + "symfony/proxy-manager-bridge": "^5.0", + "zetacomponents/system-information": "^1.1.1", + "doctrine/inflector": "^1.3" + }, + "require-dev": { + "ezsystems/ezplatform-code-style": "^0.1", + "friendsofphp/php-cs-fixer": "^2.16", + "ezsystems/doctrine-dbal-schema": "^1.0@dev", + "phpunit/phpunit": "^8.2", + "matthiasnoback/symfony-dependency-injection-test": "^4.0" + }, + "autoload": { + "psr-4": { + "EzSystems\\EzSupportToolsBundle\\": "src/bundle/", + "EzSystems\\EzSupportTools\\": "src/lib/" + } + }, + "extra": { + "_ezplatform_branch_for_behat_tests": "3.2", + "branch-alias": { + "dev-master": "2.2.x-dev", + "dev-tmp_ci_branch": "2.2.x-dev" + } + }, + "scripts": { + "fix-cs": "@php ./vendor/bin/php-cs-fixer fix -v --show-progress=estimating" + } +} diff --git a/src/bundle/Resources/config/default_settings.yaml b/src/bundle/Resources/config/default_settings.yaml index e5a82a7f..24e8e4d9 100644 --- a/src/bundle/Resources/config/default_settings.yaml +++ b/src/bundle/Resources/config/default_settings.yaml @@ -2,6 +2,10 @@ parameters: ezsettings.default.system_info_view: {} ezsettings.global.system_info_view: pjax_tab: + ibexa: + template: '@@ezdesign/system_info/my_ibexa.html.twig' + match: + SystemInfo\Identifier: 'ibexa' composer: template: '@@ezdesign/system_info/composer.html.twig' match: diff --git a/src/bundle/Resources/config/services.yaml b/src/bundle/Resources/config/services.yaml index cac7446a..3b9571e0 100644 --- a/src/bundle/Resources/config/services.yaml +++ b/src/bundle/Resources/config/services.yaml @@ -11,7 +11,7 @@ parameters: support_tools.system_info.ezc.wrapper.class: EzSystems\EzSupportToolsBundle\SystemInfo\EzcSystemInfoWrapper support_tools.system_info.collector.composer.lock_file.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector support_tools.system_info.collector.database.doctrine.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\DoctrineDatabaseSystemInfoCollector - support_tools.system_info.collector.system.ez.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzSystemInfoCollector + support_tools.system_info.collector.system.ibexa.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\IbexaSystemInfoCollector support_tools.system_info.collector.hardware.ezc.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcHardwareSystemInfoCollector support_tools.system_info.collector.php.ezc.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzcPhpSystemInfoCollector support_tools.system_info.collector.symfony.kernel.config.class: EzSystems\EzSupportToolsBundle\SystemInfo\Collector\ConfigurationSymfonyKernelSystemInfoCollector @@ -52,14 +52,13 @@ services: # SystemInfoCollectors - support_tools.system_info.collector.system.ez: - class: "%support_tools.system_info.collector.system.ez.class%" + support_tools.system_info.collector.system.ibexa: + class: "%support_tools.system_info.collector.system.ibexa.class%" arguments: - "@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 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" }] + tags: + - { name: "support_tools.system_info.collector", identifier: "ibexa" } support_tools.system_info.collector.composer.lock_file: class: "%support_tools.system_info.collector.composer.lock_file.class%" diff --git a/src/bundle/Resources/config/view.yaml b/src/bundle/Resources/config/view.yaml index 679a498e..fa8ce3ed 100644 --- a/src/bundle/Resources/config/view.yaml +++ b/src/bundle/Resources/config/view.yaml @@ -43,7 +43,7 @@ services: autowire: true arguments: $template: '@@ezdesign/ui/dashboard/block/ez.html.twig' - $ezSystemInfo: "@=service('support_tools.system_info.collector.system.ez').collect()" + $ibexaSystemInfo: "@=service('support_tools.system_info.collector.system.ibexa').collect()" $urlList: '%support_tools.ez_url_list%' tags: - { name: ezplatform.admin_ui.component, group: 'dashboard-blocks', priority: 200 } diff --git a/src/bundle/Resources/translations/systeminfo.en.xliff b/src/bundle/Resources/translations/systeminfo.en.xliff index faeb7342..7cb99576 100644 --- a/src/bundle/Resources/translations/systeminfo.en.xliff +++ b/src/bundle/Resources/translations/systeminfo.en.xliff @@ -56,6 +56,46 @@ Disabled key: disabled + + Product + Product + key: ibexa.product + + + Name + Name + key: ibexa.name + + + Version + Version + key: ibexa.version + + + End of Maintenance + End of Maintenance + key: ibexa.eom + + + End of Life + End of Life + key: ibexa.eol + + + Is Trial + Is Trial + key: ibexa.is_trial + + + Stability + Stability + key: ibexa.stability + + + You can read more about Service Life for Ibexa DXP with a business license at + You can read more about Service Life for Ibexa DXP with a business license at + key: ibexa.read_more + Hardware Hardware @@ -176,6 +216,11 @@ System Information key: systeminfo + + My Ibexa + My Ibexa + key: tab.name.ibexa + Composer Composer diff --git a/src/bundle/Resources/views/themes/admin/system_info/my_ibexa.html.twig b/src/bundle/Resources/views/themes/admin/system_info/my_ibexa.html.twig new file mode 100644 index 00000000..95dd1930 --- /dev/null +++ b/src/bundle/Resources/views/themes/admin/system_info/my_ibexa.html.twig @@ -0,0 +1,56 @@ +{% trans_default_domain "systeminfo" %} + + + +
+

{{ 'ibexa.product'|trans|desc('Product') }}

+
+ + + + + + + + + + + + + + + + + + + {% if info.isEnterprise %} + + + + + + + + + + + + {% endif %} + +
{{ 'ibexa.name'|trans|desc('Name') }}{{ info.name }}
{{ 'ibexa.version'|trans|desc('Version') }}{{ info.release }}
{{ 'ibexa.is_trial'|trans|desc('Is Trial') }} + + + +
{{ 'ibexa.stability'|trans|desc('Stability') }}{{ info.stability }}
{{ 'ibexa.eom'|trans|desc('End of Maintenance') }}* + {{ info.endOfMaintenanceDate is empty ? '' : info.endOfMaintenanceDate|date('F Y') }} +
{{ 'ibexa.eol'|trans|desc('End of Life') }}* + {{ info.endOfLifeDate is empty ? '' : info.endOfLifeDate|date('F Y') }} +
+
+ * {{ 'ibexa.read_more'|trans|desc('You can read more about Service Life for Ibexa DXP with a business license at') }} + + https://support.ibexa.co/Public/Service-Life + +
+
+
diff --git a/src/bundle/Resources/views/themes/admin/ui/dashboard/block/ez.html.twig b/src/bundle/Resources/views/themes/admin/ui/dashboard/block/ez.html.twig index fdde3b1f..5ca9efd5 100644 --- a/src/bundle/Resources/views/themes/admin/ui/dashboard/block/ez.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/dashboard/block/ez.html.twig @@ -38,7 +38,7 @@ {% else %} {{ 'dashboard.ez_version.non_stable_packages'|trans({'%stability%': ez.stability})|desc("Your setup is running with @%stability% composer packages. This is not recommended except when testing updates or during development.") }} {% endif %} - {% if ez.isEnterpise %} + {% if ez.isEnterprise %} {{ 'dashboard.ez_version.non_stable_ee'|trans({'%support_url%': urls['support']})|desc("If you need assistance, don't hesitate to get in touch with Ibexa support.")|raw }} {% endif %} @@ -79,7 +79,7 @@ |raw }} - {% elseif not ez.isEnterpise %} + {% elseif not ez.isEnterprise %} {% set badge = 'GPL' %} {% if ez.isEndOfMaintenance %} {# In the future with retrival of info from updates.ez.no we can detect missing (public) security fixes and then let this become an error #} diff --git a/src/bundle/SystemInfo/Collector/EzSystemInfoCollector.php b/src/bundle/SystemInfo/Collector/IbexaSystemInfoCollector.php similarity index 56% rename from src/bundle/SystemInfo/Collector/EzSystemInfoCollector.php rename to src/bundle/SystemInfo/Collector/IbexaSystemInfoCollector.php index 8676c38f..be8829f3 100644 --- a/src/bundle/SystemInfo/Collector/EzSystemInfoCollector.php +++ b/src/bundle/SystemInfo/Collector/IbexaSystemInfoCollector.php @@ -8,26 +8,27 @@ use EzSystems\EzPlatformCoreBundle\EzPlatformCoreBundle; use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerLockFileNotFoundException; -use EzSystems\EzSupportToolsBundle\SystemInfo\Value\EzSystemInfo; +use EzSystems\EzSupportToolsBundle\SystemInfo\Value\ComposerPackage; +use EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo; use DateTime; /** - * Collects information about the eZ installation. + * Collects information about the Ibexa installation. * - * @internal This class will greatly change in the future and should not be used as a api, planned: + * @internal This class will greatly change in the future and should not be used as an API, planned: * - Get most of this information off updates.ez.no * - Probably run this as a nightly cronjob to gather summary info * - Be able to provide warnings to admins when something (config/system setup) is not optimal - * - Be able to give information if important updates are avaiable to install - * - Or be able to tell if install is greatly outdated - * - Be able to give heads up when install is approaching end of life. + * - Be able to give information if important updates are available to the installation + * - Or be able to tell if installation is greatly outdated + * - Be able to give heads up when installation is approaching its End of Life. */ -class EzSystemInfoCollector implements SystemInfoCollector +class IbexaSystemInfoCollector implements SystemInfoCollector { /** * Estimated release dates for given releases. * - * Mainly for usage for trail to calculate TTL expiry. + * Mainly for usage for trial to calculate TTL expiry. */ const RELEASES = [ '2.5' => '2019-03-29T16:59:59+00:00', @@ -37,17 +38,17 @@ class EzSystemInfoCollector implements SystemInfoCollector ]; /** - * Dates for when releases are considered end of maintenance. + * Dates for when releases are considered End of Maintenance. * - * Open source releases are considered end of life when this date ias reached. + * Open source releases are considered End of Life when this date is reached. * - * @Note: Only enterprise/commerce installs recives fixes for security - * issues before the issues are disclosed. Also be aware the link - * below is covering Enterprise/Commerce releases, lenght of + * @Note: Only Enterprise/Commerce installations receive fixes for security + * issues before the issues are disclosed. Also, be aware the link + * below is covering Enterprise/Commerce releases, length of * maintenance for LTS releases may not be as long for open source * releases as it depends on community maintenance efforts. * - * @see: https://support.ez.no/Public/Service-Life + * @see: https://support.ibexa.co/Public/Service-Life */ const EOM = [ '2.5' => '2022-03-29T23:59:59+00:00', @@ -57,11 +58,11 @@ class EzSystemInfoCollector implements SystemInfoCollector ]; /** - * Dates for when Enterprise/Commerce installs are considered end of life. + * Dates for when Enterprise/Commerce installations are considered End of Life. * - * Meaning when they stop reciving security fixes and support. + * Meaning, when they stop receiving security fixes and support. * - * @see: https://support.ez.no/Public/Service-Life + * @see: https://support.ibexa.co/Public/Service-Life */ const EOL = [ '2.5' => '2024-03-29T23:59:59+00:00', @@ -76,16 +77,16 @@ class EzSystemInfoCollector implements SystemInfoCollector const PACKAGE_WATCH_REGEX = '/^(doctrine|ezsystems|silversolutions|symfony)\//'; /** - * Packages that identifies install as Enterpirse install. + * Packages that identify installation as "Enterprise". */ - const ENTERPISE_PACKAGES = [ + const ENTERPRISE_PACKAGES = [ 'ezsystems/ezplatform-page-builder', 'ezsystems/flex-workflow', 'ezsystems/landing-page-fieldtype-bundle', ]; /** - * Packages that identifies install as Commerce install. + * Packages that identify installation as "Commerce". */ const COMMERCE_PACKAGES = [ 'silversolutions/silver.e-shop', @@ -117,63 +118,87 @@ public function __construct(SystemInfoCollector $composerCollector, $debug = fal } /** - * Collects information about the eZ distrobution and version. + * Collects information about the Ibexa distribution and version. * - * @return \EzSystems\EzSupportToolsBundle\SystemInfo\Value\EzSystemInfo + * @throws \Exception + * + * @return \EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo */ - public function collect() + public function collect(): IbexaSystemInfo { - $ez = new EzSystemInfo(['debug' => $this->debug, 'composerInfo' => $this->composerInfo]); + $ibexa = new IbexaSystemInfo(['debug' => $this->debug, 'composerInfo' => $this->composerInfo]); if ($this->composerInfo === null) { - return $ez; + return $ibexa; } - $ez->release = EzPlatformCoreBundle::VERSION; + $ibexa->release = EzPlatformCoreBundle::VERSION; // try to extract version number, but prepare for unexpected string - [$majorVersion, $minorVersion] = array_pad(explode('.', $ez->release), 2, ''); - $eZRelease = "{$majorVersion}.{$minorVersion}"; + [$majorVersion, $minorVersion] = array_pad(explode('.', $ibexa->release), 2, ''); + $ibexaRelease = "{$majorVersion}.{$minorVersion}"; - // In case someone switches from TTL to BUL, make sure we only identify install as Trial if this is present, + // In case someone switches from TTL to BUL, make sure we only identify installation as Trial if this is present, // as well as TTL packages $hasTTLComposerRepo = \in_array('https://updates.ez.no/ttl', $this->composerInfo->repositoryUrls); - if ($package = $this->getFirstPackage(self::ENTERPISE_PACKAGES)) { - $ez->isEnterpise = true; - $ez->isTrial = $hasTTLComposerRepo && $package->license === 'TTL-2.0'; - $ez->name = 'Ibexa DXP'; + if ($package = $this->getFirstPackage(self::ENTERPRISE_PACKAGES)) { + $ibexa->isEnterprise = true; + $ibexa->isTrial = $hasTTLComposerRepo && $package->license === 'TTL-2.0'; + $ibexa->name = 'Ibexa Experience'; } if ($package = $this->getFirstPackage(self::COMMERCE_PACKAGES)) { - $ez->isCommerce = true; - $ez->isTrial = $ez->isTrial || $hasTTLComposerRepo && $package->license === 'TTL-2.0'; - $ez->name = 'Ibexa Commerce'; + $ibexa->isCommerce = true; + $ibexa->isTrial = $ibexa->isTrial || $hasTTLComposerRepo && $package->license === 'TTL-2.0'; + $ibexa->name = 'Ibexa Commerce'; } - if ($ez->isTrial && isset(self::RELEASES[$eZRelease])) { - $months = (new DateTime(self::RELEASES[$eZRelease]))->diff(new DateTime())->m; - $ez->isEndOfMaintenance = $months > 3; + if ($ibexa->isTrial && isset(self::RELEASES[$ibexaRelease])) { + $months = (new DateTime(self::RELEASES[$ibexaRelease]))->diff(new DateTime())->m; + $ibexa->isEndOfMaintenance = $months > 3; // @todo We need to detect this in a better way, this is temporary until some of the work described in class doc is done. - $ez->isEndOfLife = $months > 6; + $ibexa->isEndOfLife = $months > 6; } else { - if (isset(self::EOM[$eZRelease])) { - $ez->isEndOfMaintenance = strtotime(self::EOM[$eZRelease]) < time(); + if (isset(self::EOM[$ibexaRelease])) { + $ibexa->isEndOfMaintenance = strtotime(self::EOM[$ibexaRelease]) < time(); } - if (isset(self::EOL[$eZRelease])) { - if (!$ez->isEnterpise) { - $ez->isEndOfLife = $ez->isEndOfMaintenance; + if (isset(self::EOL[$ibexaRelease])) { + if (!$ibexa->isEnterprise) { + $ibexa->isEndOfLife = $ibexa->isEndOfMaintenance; } else { - $ez->isEndOfLife = strtotime(self::EOL[$eZRelease]) < time(); + $ibexa->isEndOfLife = strtotime(self::EOL[$ibexaRelease]) < time(); } } } - $ez->stability = $this->getStability(); + $ibexa->endOfMaintenanceDate = $this->getEOMDate($ibexaRelease); + $ibexa->endOfLifeDate = $this->getEOLDate($ibexaRelease); + $ibexa->stability = $this->getStability(); + + return $ibexa; + } + + /** + * @throws \Exception + */ + private function getEOMDate(string $ibexaRelease): ?\DateTime + { + return isset(self::EOM[$ibexaRelease]) ? + new DateTime(self::EOM[$ibexaRelease]) : + null; + } - return $ez; + /** + * @throws \Exception + */ + private function getEOLDate(string $ibexaRelease): ?\DateTime + { + return isset(self::EOL[$ibexaRelease]) ? + new DateTime(self::EOL[$ibexaRelease]) : + null; } - private function getStability() + private function getStability(): string { $stabilityFlags = array_flip(JsonComposerLockSystemInfoCollector::STABILITIES); @@ -182,7 +207,7 @@ private function getStability() $stabilityFlags[$this->composerInfo->minimumStability] : $stabilityFlags['stable']; - // Check if any of the watche packages has lower stability then root + // Check if any of the watched packages has lower stability than root foreach ($this->composerInfo->packages as $name => $package) { if (!preg_match(self::PACKAGE_WATCH_REGEX, $name)) { continue; @@ -200,12 +225,14 @@ private function getStability() return JsonComposerLockSystemInfoCollector::STABILITIES[$stabilityFlag]; } - private function getFirstPackage($packageNames) + private function getFirstPackage($packageNames): ?ComposerPackage { foreach ($packageNames as $packageName) { if (isset($this->composerInfo->packages[$packageName])) { return $this->composerInfo->packages[$packageName]; } } + + return null; } } diff --git a/src/bundle/SystemInfo/Value/EzSystemInfo.php b/src/bundle/SystemInfo/Value/IbexaSystemInfo.php similarity index 78% rename from src/bundle/SystemInfo/Value/EzSystemInfo.php rename to src/bundle/SystemInfo/Value/IbexaSystemInfo.php index 7db5e266..c76bc683 100644 --- a/src/bundle/SystemInfo/Value/EzSystemInfo.php +++ b/src/bundle/SystemInfo/Value/IbexaSystemInfo.php @@ -9,16 +9,16 @@ use eZ\Publish\API\Repository\Values\ValueObject; /** - * Value for information about the eZ installation. + * Value for information about the Ibexa installation. * * @internal This class will greatly change in the future and should not be used as an api. */ -class EzSystemInfo extends ValueObject implements SystemInfo +class IbexaSystemInfo extends ValueObject implements SystemInfo { /** * @var string */ - public $name = 'Ibexa Platform'; + public $name = 'Ibexa Open Source'; /** * @var string|null Either string like '2.5' or null if not detected. @@ -28,7 +28,7 @@ class EzSystemInfo extends ValueObject implements SystemInfo /** * @var bool */ - public $isEnterpise = false; + public $isEnterprise = false; /** * @var bool @@ -40,11 +40,21 @@ class EzSystemInfo extends ValueObject implements SystemInfo */ public $isEndOfMaintenance = true; + /** + * @var \DateTime + */ + public $endOfMaintenanceDate; + /** * @var bool */ public $isEndOfLife = true; + /** + * @var \DateTime + */ + public $endOfLifeDate; + /** * @var bool */ diff --git a/src/bundle/Tests/SystemInfo/Collector/EzSystemInfoCollectorTest.php b/src/bundle/Tests/SystemInfo/Collector/IbexaSystemInfoCollectorTest.php similarity index 73% rename from src/bundle/Tests/SystemInfo/Collector/EzSystemInfoCollectorTest.php rename to src/bundle/Tests/SystemInfo/Collector/IbexaSystemInfoCollectorTest.php index a5a98164..59145e41 100644 --- a/src/bundle/Tests/SystemInfo/Collector/EzSystemInfoCollectorTest.php +++ b/src/bundle/Tests/SystemInfo/Collector/IbexaSystemInfoCollectorTest.php @@ -9,11 +9,11 @@ namespace SystemInfo\Collector; use EzSystems\EzPlatformCoreBundle\EzPlatformCoreBundle; -use EzSystems\EzSupportToolsBundle\SystemInfo\Collector\EzSystemInfoCollector; +use EzSystems\EzSupportToolsBundle\SystemInfo\Collector\IbexaSystemInfoCollector; use EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector; use PHPUnit\Framework\TestCase; -class EzSystemInfoCollectorTest extends TestCase +class IbexaSystemInfoCollectorTest extends TestCase { public function testCollect(): void { @@ -21,9 +21,9 @@ public function testCollect(): void __DIR__ . '/_fixtures/composer.lock', __DIR__ . '/_fixtures/composer.json' ); - $systemInfoCollector = new EzSystemInfoCollector($composerCollector); + $systemInfoCollector = new IbexaSystemInfoCollector($composerCollector); $systemInfo = $systemInfoCollector->collect(); - self::assertSame('Ibexa Platform', $systemInfo->name); + self::assertSame('Ibexa Open Source', $systemInfo->name); self::assertSame(EzPlatformCoreBundle::VERSION, $systemInfo->release); } } diff --git a/src/bundle/Tests/SystemInfo/Collector/_fixtures/composer.json b/src/bundle/Tests/SystemInfo/Collector/_fixtures/composer.json index fd529cfa..c9f50a34 100644 --- a/src/bundle/Tests/SystemInfo/Collector/_fixtures/composer.json +++ b/src/bundle/Tests/SystemInfo/Collector/_fixtures/composer.json @@ -1,12 +1,12 @@ { "name": "ezsystems/ezplatform-ee", - "description": "eZ Platform Enterprise Edition distribution", + "description": "Ibexa Experience distribution", "homepage": "https://github.com/ezsystems/ezplatform-ee", "license": "proprietary", "type": "project", "authors": [ { - "name": "eZ dev-team & eZ Community", + "name": "Ibexa dev-team & Ibexa Community", "homepage": "https://github.com/ezsystems/ezplatform-ee/contributors" } ], diff --git a/src/lib/Component/Dashboard/EzInfoTwigComponent.php b/src/lib/Component/Dashboard/EzInfoTwigComponent.php index 43f5096f..cc63f34e 100644 --- a/src/lib/Component/Dashboard/EzInfoTwigComponent.php +++ b/src/lib/Component/Dashboard/EzInfoTwigComponent.php @@ -9,7 +9,7 @@ namespace EzSystems\EzSupportTools\Component\Dashboard; use EzSystems\EzPlatformAdminUi\Component\Renderable; -use EzSystems\EzSupportToolsBundle\SystemInfo\Value\EzSystemInfo; +use EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo; use Twig\Environment; class EzInfoTwigComponent implements Renderable @@ -23,8 +23,8 @@ class EzInfoTwigComponent implements Renderable /** @var array */ protected $parameters; - /** @var \EzSystems\EzSupportToolsBundle\SystemInfo\Value\EzSystemInfo */ - private $ezSystemInfo; + /** @var \EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo */ + private $ibexaSystemInfo; /** @var array */ private $urlList; @@ -32,21 +32,21 @@ class EzInfoTwigComponent implements Renderable /** * @param \Twig\Environment $twig * @param string $template - * @param \EzSystems\EzSupportToolsBundle\SystemInfo\Value\EzSystemInfo $ezSystemInfo + * @param \EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo $ibexaSystemInfo * @param array $urlList * @param array $parameters */ public function __construct( Environment $twig, string $template, - EzSystemInfo $ezSystemInfo, + IbexaSystemInfo $ibexaSystemInfo, array $urlList, array $parameters = [] ) { $this->twig = $twig; $this->template = $template; $this->parameters = $parameters; - $this->ezSystemInfo = $ezSystemInfo; + $this->ibexaSystemInfo = $ibexaSystemInfo; $this->urlList = $urlList; } @@ -61,7 +61,7 @@ public function render(array $parameters = []): string return $this->twig->render( $this->template, - $parameters + ['urls' => $urls, 'ez' => $this->ezSystemInfo] + $this->parameters + $parameters + ['urls' => $urls, 'ez' => $this->ibexaSystemInfo] + $this->parameters ); } @@ -72,7 +72,7 @@ private function replaceUrlPlaceholders(): array { $urls = $this->urlList; foreach ($this->urlList as $urlName => $url) { - foreach ($this->ezSystemInfo as $attribute => $value) { + foreach ($this->ibexaSystemInfo as $attribute => $value) { if (\is_string($value) && \strpos($url, '{ez.' . $attribute . '}') !== false) { $urls[$urlName] = \str_replace('{ez.' . $attribute . '}', $value, $url); }