Skip to content

Commit

Permalink
Assets::favicons(): warnings for depreacted keys
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Dec 7, 2024
1 parent ae392f4 commit 5e716aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 73 deletions.
11 changes: 6 additions & 5 deletions src/Panel/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}

Expand Down
68 changes: 0 additions & 68 deletions tests/Panel/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 5e716aa

Please sign in to comment.