Create twig function to display version of chill-bundles package

This commit is contained in:
2026-01-06 10:14:30 +01:00
parent 7766b0fe1f
commit 6a8c9b37d9
5 changed files with 44 additions and 5 deletions

View File

@@ -2,8 +2,8 @@
<p>
{{ 'This program is free software: you can redistribute it and/or modify it under the terms of the <strong>GNU Affero General Public License</strong>'|trans|raw }}
<br/>
{% if chillBundlesVersion is defined %}
{{ 'footer.Running chill version %version%'|trans({ '%version%': chillBundlesVersion.getFormattedVersion() }) }}
{% if get_chill_version() %}
{{ 'footer.Running chill version %version%'|trans({ '%version%': get_chill_version() }) }}
{% endif %}
<br/>
<a name="bottom" class="btn text-white" href="https://gitea.champs-libres.be/Chill-project/manuals/releases" target="_blank">

View File

@@ -13,9 +13,9 @@ namespace Chill\MainBundle\Service;
use Composer\InstalledVersions;
class VersionProvider
readonly class VersionProvider
{
public function __construct(private readonly string $packageName) {}
public function __construct(private string $packageName) {}
public function getVersion(): string
{

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Templating;
use Chill\MainBundle\Service\VersionProvider;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class VersionRenderExtension extends AbstractExtension
{
public function __construct(
private readonly VersionProvider $versionProvider,
) {}
public function getFunctions(): array
{
return [
new TwigFunction('get_chill_version', $this->getChillVersion(...)),
];
}
public function getChillVersion(): string
{
return $this->versionProvider->getFormattedVersion();
}
}

View File

@@ -118,4 +118,4 @@ services:
Chill\MainBundle\Service\VersionProvider:
arguments:
$packageName: ''
$packageName: 'chill-project/chill-bundles'

View File

@@ -66,3 +66,7 @@ services:
resource: './../../Templating/Listing'
Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface: '@Chill\MainBundle\Templating\Listing\FilterOrderHelperFactory'
Chill\MainBundle\Templating\VersionRenderExtension:
tags:
- { name: twig.extension }