From 598f1ccfdd5f12fea0f1f0d9f2c83327d7f979f8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 5 Jan 2026 12:52:19 +0100 Subject: [PATCH] VersionProvider service to display version of chill deployed in the application footer --- composer.json | 1 + .../Resources/views/Layout/_footer.html.twig | 2 + .../Service/VersionProvider.php | 50 +++++++++++++++++++ .../ChillMainBundle/config/services.yaml | 4 ++ 4 files changed, 57 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Service/VersionProvider.php diff --git a/composer.json b/composer.json index 829d5e7db..8fc4c300e 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "ext-openssl": "*", "ext-redis": "*", "ext-zlib": "*", + "composer-runtime-api": "*", "champs-libres/wopi-bundle": "dev-symfony-v5@dev", "champs-libres/wopi-lib": "dev-master@dev", "doctrine/data-fixtures": "^1.8", diff --git a/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig index df6ba912b..18e8d2a67 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig @@ -2,6 +2,8 @@

{{ 'This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License'|trans|raw }}
+ {{ 'Running chill version %version%'|trans({ '%version%': chillBundlesVersion }) }} +
{{ 'User manual'|trans }} diff --git a/src/Bundle/ChillMainBundle/Service/VersionProvider.php b/src/Bundle/ChillMainBundle/Service/VersionProvider.php new file mode 100644 index 000000000..c35f22933 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Service/VersionProvider.php @@ -0,0 +1,50 @@ +packageName = $packageName; + } + + public function getVersion(): string + { + try { + $version = InstalledVersions::getPrettyVersion($this->packageName); + + if (null === $version) { + return 'unknown'; + } + + return $version; + } catch (\OutOfBoundsException $e) { + return 'unknown'; + } + } + + public function getFormattedVersion(): string + { + $version = $this->getVersion(); + + if ('unknown' === $version) { + return 'Version unavailable'; + } + + return 'v'.$version; + } +} diff --git a/src/Bundle/ChillMainBundle/config/services.yaml b/src/Bundle/ChillMainBundle/config/services.yaml index d8d4a475d..0a2154bcb 100644 --- a/src/Bundle/ChillMainBundle/config/services.yaml +++ b/src/Bundle/ChillMainBundle/config/services.yaml @@ -115,3 +115,7 @@ services: $vienEntityInfoProviders: !tagged_iterator chill_main.entity_info_provider Chill\MainBundle\Action\User\UpdateProfile\UpdateProfileCommandHandler: ~ + + Chill\MainBundle\Service\VersionProvider: + arguments: + $packageName: ''