Hasnayeen / themes

Themes for Filament panels.
MIT License
217 stars 30 forks source link

[Bug]: Theme collection #6

Closed Thiktak closed 1 year ago

Thiktak commented 1 year ago

What happened?

Hello,

I think, we got a regression.

On class Themes, the collection definition is Name=>class

        $this->collection = collect([
            DefaultTheme::getName() => DefaultTheme::class,
            Nord::getName() => Nord::class,
            Sunset::getName() => Sunset::class,
        ]);

but make is returning "default". By the way, this collection is key=>class. No need to first, but a simple get(). Or need to reverse the collection key/value.

    public function make(string $theme): Theme
    {
        $name = $this->collection->get($theme);
        if ($name) {
            return new $name;
        }
    }

Between the __construct & make, the collection changed :

Illuminate\Support\Collection {#1478 ▼ // vendor\hasnayeen\themes\src\Themes.php:42
  #items: array:3 [▼
    "default" => "default"
    "nord" => "nord"
    "sunset" => "sunset"
  ]
  #escapeWhenCastingToString: false
}

How to reproduce the bug

Install

Package Version

v3.0.10

PHP Version

8.2.4

Laravel Version

v3.0.39

Notes

No response

Hasnayeen commented 1 year ago

A fix has been pushed 04a7476, should be ok now