Skip to content

Commit 5ccacdb

Browse files
committed
Refactor menu item icon handling.
1 parent 4a6467e commit 5ccacdb

File tree

4 files changed

+0
-52
lines changed

4 files changed

+0
-52
lines changed

src/Form/Fields/Types/AbstractMenuItemType.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,6 @@
44

55
abstract class AbstractMenuItemType
66
{
7-
protected ?string $icon = null;
8-
9-
public function getIcon(): ?string
10-
{
11-
return $this->icon;
12-
}
13-
14-
public function icon(?string $icon): static
15-
{
16-
$this->icon = $icon;
17-
18-
return $this;
19-
}
20-
217
abstract public function getAlias(): string;
228

239
public function isUrlType(): bool

src/Form/Fields/Types/LinkableMenuItemType.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ class LinkableMenuItemType extends AbstractMenuItemType
1818
public function __construct(string $model)
1919
{
2020
$this->model = $model;
21-
$this->icon = 'heroicon-o-link';
22-
23-
// Set icon based on model if it has a getMorphClass method
24-
$modelInstance = app($model);
25-
if (method_exists($modelInstance, 'getMorphClass')) {
26-
$morphClass = $modelInstance->getMorphClass();
27-
$this->icon = $this->getIconForMorphClass($morphClass);
28-
}
2921
}
3022

3123
public static function make(string $model): static
@@ -122,26 +114,6 @@ protected function getHelperText(): string
122114
]);
123115
}
124116

125-
protected function getIconForMorphClass(string $morphClass): string
126-
{
127-
// Check config for exact morph class match
128-
$configuredIcons = FilamentFlexibleContentBlockPages::config()
129-
->getMenuModelIcons();
130-
131-
if (isset($configuredIcons[$morphClass])) {
132-
return $configuredIcons[$morphClass];
133-
}
134-
135-
// Fallback to pattern matching for backwards compatibility
136-
foreach ($configuredIcons as $pattern => $icon) {
137-
if (str_contains($morphClass, $pattern)) {
138-
return $icon;
139-
}
140-
}
141-
142-
// Final fallback to default icon
143-
return 'heroicon-o-link';
144-
}
145117

146118
public function isModelType(): bool
147119
{

src/Form/Fields/Types/RouteMenuItemType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ class RouteMenuItemType extends AbstractMenuItemType
99
{
1010
const TYPE_ROUTE = 'route';
1111

12-
public function __construct()
13-
{
14-
$this->icon = 'heroicon-o-map';
15-
}
16-
1712
public static function make(?string $model = null): static
1813
{
1914
return new static;

src/Form/Fields/Types/UrlMenuItemType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ class UrlMenuItemType extends AbstractMenuItemType
88
{
99
const TYPE_URL = 'url';
1010

11-
public function __construct()
12-
{
13-
$this->icon = 'heroicon-o-link';
14-
}
15-
1611
public static function make(?string $model = null): static
1712
{
1813
return new static;

0 commit comments

Comments
 (0)