Closed bilogic closed 4 months ago
We need to do that otherwise calls made to the facade BEFORE the singleton is registered get lost, since they are overridden by the singleton registration.
@danharrin
Thanks, but I'm still confused as to why
AssetManager::register()
(meaning the singleton has been registered) FilamentServiceProvider
ran next but still called the FilamentAsset
facade's static register()
Do you know what can be causing this? Is there a way to inject CSS after filament's? I have exhausted all means and the only way was to include it in my custom field's blade.
So you have no problem injecting before Filament's, is there a reason you want it after? Specificity?
Alright, there are 2 issues here
@assets
- my ServiceProvider ran first and led to
AssetManager::register()
(meaning the singleton has been registered)FilamentServiceProvider
ran next but still called theFilamentAsset
facade'sstatic register()
FilamentServiceProvider
decided to call the static
method even though the singleton has already been registered. I still have no answer as to how and why that happened.Will probably need some extra checks to see if the singleton has been resolved before registering another resolving()
callback
If I may, I do not think filament needs to have static methods in a facade to achieve its aims, removing them will make behavior more standardized and easier to debug.
Removing them will cause breaking changes for asset registration in register()
.
It's something we will look at dealing with in v4 but its not possible in v3.
Yea, v4 is good enough for me. Thanks!
Package
filament/filament
Package Version
v3.2.73
Laravel Version
10.48.10
Livewire Version
v3.4.12
PHP Version
8.1.28
Problem description
At the core of it, the problem is:
When filamentphp calls
\Filament\Support\Facades\FilamentAsset::register()
fromFilamentServiceProvider::packageBooted()
, it goes straight to thestatic register()
of the facade https://github.com/filamentphp/support/blob/49637c225f9eb72380a3dc54e9fd951563955770/src/Facades/FilamentAsset.php#L37When my ServiceProvider calls
\Filament\Support\Facades\FilamentAsset::register()
, it goes to Laravel'sAliasLoader.php
and thenAssetManager::register()
https://github.com/filamentphp/support/blob/49637c225f9eb72380a3dc54e9fd951563955770/src/Assets/AssetManager.php#L46Why does the filamentphp call goes to the
static register()
which does not follow Laravel's convention? This leads to a very confusing code path that one cannot follow by just reading codeThis surfaced because I needed to override some CSS of easyMDE, so wanted to insert them after filament's by registering later, but was unable to do so despite trying several methods e.g
$this->booted(function() {...});
,static::resolved(function (AssetManager $assetManager)...
Expected behavior
There is probably some reason why
\Filament\Support\Facades\FilamentAsset::register()
exists, but it does not seem to follow Laravel convention. Thus, in my view:\Filament\Support\Facades\FilamentAsset::register()
should not existFilamentServiceProvider::packageBooted()
,\Filament\Support\Facades\FilamentAsset::register()
should callAssetManager::register()
Or it would greatly help if someone could clarify why things work as described in my problem description
Steps to reproduce
It happens in every repository that uses filament, just load any filament page after setting XDebug breakpoints at
Reproduction repository
n/a
Relevant log output
No response