diff --git a/composer.json b/composer.json index cd75f55..b4796d0 100644 --- a/composer.json +++ b/composer.json @@ -1,4 +1,6 @@ { + "name": "caboulot/omo", + "version": "0.0.0", "type": "project", "license": "WTFPL", "minimum-stability": "stable", diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index b1dd948..ec3ea3c 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -21,6 +21,7 @@ twig: route: 'app_tools_city' - label: 'Osmose' route: 'app_tools_osmose' + versionGetter: '@App\Service\VersionGetter' when@test: twig: diff --git a/config/services.yaml b/config/services.yaml index ebd3d95..81f8d9d 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -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 diff --git a/src/Service/VersionGetter.php b/src/Service/VersionGetter.php new file mode 100644 index 0000000..8d8130c --- /dev/null +++ b/src/Service/VersionGetter.php @@ -0,0 +1,18 @@ +projectDir.'/composer.json'), true); + return isset($data['version']) ? $data['version'] : $defaultVersion; + } catch (\Exception $exception) { + return ''; + } + } + +} diff --git a/templates/_header.html.twig b/templates/_header.html.twig index e2d25f0..324c429 100644 --- a/templates/_header.html.twig +++ b/templates/_header.html.twig @@ -1,7 +1,7 @@