Browse Source

Introduit un numéro de version

master
vincent 20 hours ago
parent
commit
956f16b212
5 changed files with 26 additions and 1 deletions
  1. +2
    -0
      composer.json
  2. +1
    -0
      config/packages/twig.yaml
  3. +4
    -0
      config/services.yaml
  4. +18
    -0
      src/Service/VersionGetter.php
  5. +1
    -1
      templates/_header.html.twig

+ 2
- 0
composer.json View File

@ -1,4 +1,6 @@
{
"name": "caboulot/omo",
"version": "0.0.0",
"type": "project",
"license": "WTFPL",
"minimum-stability": "stable",


+ 1
- 0
config/packages/twig.yaml View File

@ -21,6 +21,7 @@ twig:
route: 'app_tools_city'
- label: 'Osmose'
route: 'app_tools_osmose'
versionGetter: '@App\Service\VersionGetter'
when@test:
twig:


+ 4
- 0
config/services.yaml View File

@ -13,6 +13,10 @@ services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
# pass this value to any $projectDir argument for any service
# that's created in this file (including controller arguments)
$projectDir: '%kernel.project_dir%'
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name


+ 18
- 0
src/Service/VersionGetter.php View File

@ -0,0 +1,18 @@
<?php
namespace App\Service;
class VersionGetter {
public function __construct(private $projectDir) {}
public function getVersion($defaultVersion = null): ?string {
try {
$data = json_decode(file_get_contents($this->projectDir.'/composer.json'), true);
return isset($data['version']) ? $data['version'] : $defaultVersion;
} catch (\Exception $exception) {
return '';
}
}
}

+ 1
- 1
templates/_header.html.twig View File

@ -1,7 +1,7 @@
<header>
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="{{ path('app_home') }}" title="{{ long_title }}">{{ title }}</a>
<a class="navbar-brand" href="{{ path('app_home') }}" title="{{ long_title }} {{ versionGetter.getVersion() }}">{{ title }} </a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>


Loading…
Cancel
Save