From c84f0317654c934eddff4affd1272b4b27da579f Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Mon, 1 Sep 2025 14:16:11 +0200 Subject: [PATCH 1/3] Update composer require command in testing.yml --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 512823c..45f6f1f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -31,7 +31,7 @@ jobs: composer config prefer-stable true composer config repositories.0 '{"type": "path", "url": "'$GITHUB_WORKSPACE'/packages/uebertool-companion", "options": {"symlink": false}}' composer config repositories.1 '{"type": "composer", "url": "https://asset-packagist.org"}' - composer require drupal/core-dev:^11.1.1 \ + composer require -W drupal/core-dev:^11.1.1 \ drush/drush \ ueberbit/uebertool_companion From 193b2ce9bbacdf09d7366fdebe20e15dc9e93847 Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Mon, 1 Sep 2025 14:22:33 +0200 Subject: [PATCH 2/3] Run tests on every branch --- .github/workflows/testing.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 45f6f1f..4125768 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -2,9 +2,6 @@ name: Testing on: push: - branches: - - main - - feature/* env: SIMPLETEST_DB: sqlite://localhost/sites/default/files/.ht.sqlite From a6029c3805ba0e73d987d64bb58bbcd938985aff Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Mon, 1 Sep 2025 22:18:43 +0200 Subject: [PATCH 3/3] Add depreaction for test --- .../src/Twig/Extension/TwigExtrasExtension.php | 9 ++++++++- .../tests/src/Kernel/TwigExtrasExtensionTest.php | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/uebertool-companion/modules/uebertool_twig/src/Twig/Extension/TwigExtrasExtension.php b/packages/uebertool-companion/modules/uebertool_twig/src/Twig/Extension/TwigExtrasExtension.php index 8e88f0d..8eb09df 100644 --- a/packages/uebertool-companion/modules/uebertool_twig/src/Twig/Extension/TwigExtrasExtension.php +++ b/packages/uebertool-companion/modules/uebertool_twig/src/Twig/Extension/TwigExtrasExtension.php @@ -40,7 +40,7 @@ public function getFilters(): array { /** * {@inheritdoc} */ - public function getFunctions() { + public function getFunctions(): array { return [ new TwigFunction('button', [$this, 'getButton']), new TwigFunction('buttons', [$this, 'getButtons']), @@ -218,6 +218,12 @@ public function linkText(?array $build): string { */ public function linkAttributes(?array $build): Attribute { if ($this->isLink($build)) { + $linkAttributes = new Attribute(); + $linkAttributes->addClass($build['#url']->getOption('attributes')['class'] ?? []); + if ((string) $linkAttributes) { + @trigger_error('Handling the class attribute from the Url object is deprecated. Use $element["#attributes"] instead. See https://www.drupal.org/node/3494015', E_USER_DEPRECATED); + } + $element = $this->renderer->renderInIsolation($build); $dom = Html::load($element); $xpath = new \DOMXPath($dom); @@ -228,6 +234,7 @@ public function linkAttributes(?array $build): Attribute { return $item->nodeValue; }, iterator_to_array($element->attributes->getIterator()))); $attribute->removeAttribute('href'); + $attribute->merge($linkAttributes); return $attribute; } diff --git a/packages/uebertool-companion/modules/uebertool_twig/tests/src/Kernel/TwigExtrasExtensionTest.php b/packages/uebertool-companion/modules/uebertool_twig/tests/src/Kernel/TwigExtrasExtensionTest.php index e614954..d240130 100644 --- a/packages/uebertool-companion/modules/uebertool_twig/tests/src/Kernel/TwigExtrasExtensionTest.php +++ b/packages/uebertool-companion/modules/uebertool_twig/tests/src/Kernel/TwigExtrasExtensionTest.php @@ -109,19 +109,24 @@ public function testLinkAttributes(): void { 'class' => 'foo', ], ])); + } + #[IgnoreDeprecations] + public function testLinkAttributesWithUrlOptions(): void { // Collect attributes from link options. $url = Url::fromUri('https://example.com'); $url->setOption('attributes', [ 'class' => 'foo', 'data-foo' => 'bar', ]); + + $this->expectDeprecation('Handling the class attribute from the Url object is deprecated. Use $element["#attributes"] instead. See https://www.drupal.org/node/3494015'); $this->assertEquals(new Attribute([ + 'data-foo' => 'bar', + 'target' => '_blank', 'class' => [ 'foo', ], - 'data-foo' => 'bar', - 'target' => '_blank', ]), $this->twigExtension->linkAttributes([ '#type' => 'link', '#title' => 'Link text',