From 66cc9f49638d13b5603cdae62b1fb452da66fe64 Mon Sep 17 00:00:00 2001 From: Nico Hoffmann Date: Sat, 7 Dec 2024 19:12:15 +0100 Subject: [PATCH] `Assets::favicons()`: warnings for depreacted keys --- src/Panel/Assets.php | 11 +++--- tests/Panel/AssetsTest.php | 68 -------------------------------------- 2 files changed, 6 insertions(+), 73 deletions(-) diff --git a/src/Panel/Assets.php b/src/Panel/Assets.php index 6396c89aa2..5da0f4e12d 100644 --- a/src/Panel/Assets.php +++ b/src/Panel/Assets.php @@ -3,6 +3,7 @@ namespace Kirby\Panel; use Kirby\Cms\App; +use Kirby\Cms\Helpers; use Kirby\Cms\Url; use Kirby\Exception\Exception; use Kirby\Exception\InvalidArgumentException; @@ -116,11 +117,7 @@ public function external(): array } /** - * Returns array of favicon icons - * based on config option - * - * @todo Deprecate `url` option in v5, use `href` option instead - * @todo Deprecate `rel` usage as array key in v5, use `rel` option instead + * Returns array of favicon icons based on config option * * @throws \Kirby\Exception\InvalidArgumentException */ @@ -161,12 +158,16 @@ public function favicons(): array foreach ($icons as $rel => &$icon) { // TODO: remove this backward compatibility check in v6 if (isset($icon['url']) === true) { + Helpers::deprecated('`panel.favicon` option: use `href` instead of `url` attribute'); + $icon['href'] = $icon['url']; unset($icon['url']); } // TODO: remove this backward compatibility check in v6 if (is_string($rel) === true && isset($icon['rel']) === false) { + Helpers::deprecated('`panel.favicon` option: use `rel` attribute instead of passing string as key'); + $icon['rel'] = $rel; } diff --git a/tests/Panel/AssetsTest.php b/tests/Panel/AssetsTest.php index 1457e164ef..203bf2ba4e 100644 --- a/tests/Panel/AssetsTest.php +++ b/tests/Panel/AssetsTest.php @@ -335,74 +335,6 @@ public function testFaviconsWithCustomUrl(): void $this->assertSame($base . '/favicon.svg', $favicons[2]['href']); } - /** - * @todo Remove backward compatibility part test in v5 - */ - public function testFaviconsWithRelIndex(): void - { - // array - $this->app->clone([ - 'options' => [ - 'panel' => [ - 'favicon' => [ - 'shortcut icon' => [ - 'type' => 'image/svg+xml', - 'url' => 'assets/my-favicon.svg', - ], - 'alternate icon' => [ - 'type' => 'image/png', - 'url' => 'assets/my-favicon.png', - ] - ] - ] - ] - ]); - - // default asset setup - $assets = new Assets(); - $favicons = $assets->favicons(); - - // icons - $this->assertSame('shortcut icon', $favicons[0]['rel']); - $this->assertSame('/assets/my-favicon.svg', $favicons[0]['href']); - $this->assertSame('alternate icon', $favicons[1]['rel']); - $this->assertSame('/assets/my-favicon.png', $favicons[1]['href']); - } - - /** - * @todo Remove backward compatibility part test in v5 - */ - public function testFaviconsWithUrlOption(): void - { - // array - $this->app->clone([ - 'options' => [ - 'panel' => [ - 'favicon' => [ - [ - 'rel' => 'shortcut icon', - 'type' => 'image/svg+xml', - 'url' => 'assets/my-favicon.svg', - ], - [ - 'rel' => 'alternate icon', - 'type' => 'image/png', - 'url' => 'assets/my-favicon.png', - ] - ] - ] - ] - ]); - - // default asset setup - $assets = new Assets(); - $favicons = $assets->favicons(); - - // icons - $this->assertSame('/assets/my-favicon.svg', $favicons[0]['href']); - $this->assertSame('/assets/my-favicon.png', $favicons[1]['href']); - } - /** * @covers ::icons */