1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
From: =?utf-8?q?David_Pr=C3=A9vot?= <david@tilapin.org>
Date: Sun, 4 May 2025 00:21:42 +0200
Subject: Workaround the lack of InstalledVersions::getVersion
Forwarded: not-needed
---
.../DebugBundle/DependencyInjection/Configuration.php | 2 +-
.../FrameworkBundle/DependencyInjection/Configuration.php | 2 +-
.../DependencyInjection/MainConfiguration.php | 2 +-
.../Bundle/TwigBundle/DependencyInjection/Configuration.php | 2 +-
.../WebProfilerBundle/DependencyInjection/Configuration.php | 2 +-
.../Component/Config/Definition/Builder/NodeDefinition.php | 13 +++++++++++++
.../Config/Tests/Definition/Builder/NodeDefinitionTest.php | 2 +-
7 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php
index a72034d..561f0bf 100644
--- a/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php
@@ -27,7 +27,7 @@ class Configuration implements ConfigurationInterface
$rootNode = $treeBuilder->getRootNode();
$rootNode
- ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/debug.html', 'symfony/debug-bundle')
+ ->docUrlNoComposer('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/debug.html', 'symfony/debug-bundle', '@VERSION@')
->children()
->integerNode('max_items')
->info('Max number of displayed items past the first level, -1 means no limit.')
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index d66a5c6..1c1c61a2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -76,7 +76,7 @@ class Configuration implements ConfigurationInterface
$rootNode = $treeBuilder->getRootNode();
$rootNode
- ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/framework.html', 'symfony/framework-bundle')
+ ->docUrlNoComposer('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/framework.html', 'symfony/framework-bundle', '@VERSION@')
->beforeNormalization()
->ifTrue(fn ($v) => !isset($v['assets']) && isset($v['templating']) && class_exists(Package::class))
->then(function ($v) {
diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
index 0a2d32c..ce397d8 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
@@ -55,7 +55,7 @@ class MainConfiguration implements ConfigurationInterface
$rootNode = $tb->getRootNode();
$rootNode
- ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/security.html', 'symfony/security-bundle')
+ ->docUrlNoComposer('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/security.html', 'symfony/security-bundle', '@VERSION@')
->beforeNormalization()
->always()
->then(function ($v) {
diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
index 354e1a4..e952a92 100644
--- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
@@ -33,7 +33,7 @@ class Configuration implements ConfigurationInterface
$rootNode = $treeBuilder->getRootNode();
$rootNode
- ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/twig.html', 'symfony/twig-bundle')
+ ->docUrlNoComposer('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/twig.html', 'symfony/twig-bundle', '@VERSION@')
->beforeNormalization()
->ifTrue(fn ($v) => \is_array($v) && \array_key_exists('exception_controller', $v))
->then(function ($v) {
diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php
index 649bf45..f3ec64c 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php
@@ -33,7 +33,7 @@ class Configuration implements ConfigurationInterface
$treeBuilder
->getRootNode()
- ->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/web_profiler.html', 'symfony/web-profiler-bundle')
+ ->docUrlNoComposer('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/web_profiler.html', 'symfony/web-profiler-bundle', '@VERSION@')
->children()
->arrayNode('toolbar')
->info('Profiler toolbar configuration')
diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
index fdfbdab..9e67c3d 100644
--- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
+++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
@@ -97,6 +97,19 @@ abstract class NodeDefinition implements NodeParentInterface
]));
}
+ public function docUrlNoComposer(string $uri, ?string $package = null, ?string $version = null): static
+ {
+ if ($package) {
+ preg_match('/^(\d+)\.(\d+)\.(\d+)/', $version ?? '', $m);
+ }
+
+ return $this->attribute('docUrl', strtr($uri, [
+ '{package}' => $package ?? '',
+ '{version:major}' => $m[1] ?? '',
+ '{version:minor}' => $m[2] ?? '',
+ ]));
+ }
+
/**
* Sets an attribute on the node.
*
diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php
index baa4518..3f233bb 100644
--- a/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php
+++ b/src/Symfony/Component/Config/Tests/Definition/Builder/NodeDefinitionTest.php
@@ -39,7 +39,7 @@ class NodeDefinitionTest extends TestCase
public function testDocUrl()
{
$node = new ArrayNodeDefinition('node');
- $node->docUrl('https://example.com/doc/{package}/{version:major}.{version:minor}', 'phpunit/phpunit');
+ $node->docUrlNoComposer('https://example.com/doc/{package}/{version:major}.{version:minor}', 'phpunit/phpunit', '12.1.4');
$r = new \ReflectionObject($node);
$p = $r->getProperty('attributes');
|