filament
filament copied to clipboard
access app cluster from plugin class
Package
filament/filament
Package Version
v3.2.72
Laravel Version
v11.5.0
Livewire Version
v3.4.11
PHP Version
v8.2.10
Problem description
from a plugin class, trying to allow users to set the plugin resource in a cluster
the Reproduction repository already configured to use CuratorPlugin
and there is a cluster in the app Life::class
when using the plugin like:
\Awcodes\Curator\CuratorPlugin::make()
->cluster(Life::class)
in the plugin resource:
public static function getCluster(): ?string
{
return CuratorPlugin::get()->getCluster();
}
you'll see the error
Call to a member function getPlugin() on null
its look like the clusters not ready when the plugin initialized?!
Expected behavior
when accessing the cluster from a config
public static function getCluster(): ?string
{
return config('curator.resources.cluster');
}
it works fin, but not if it set from the class CuratorPlugin
btw the CuratorPlugin
was an example, tested with other of my packages got the same error.
Steps to reproduce
the Reproduction repository already setup with a cluster and the plugin installed and configerd
using a fork of the plugin: https://github.com/atmonshi/filament-curator/tree/cluster-panel
when accessing the /admin
you will get the error Call to a member function getPlugin() on null
disable this https://github.com/atmonshi/filament-curator/blob/669af3898dbc74e1dd3803d13c67e9d98b338981/src/Resources/MediaResource.php#L69
to make it work
Reproduction repository
https://github.com/atmonshi/issue-cluster
Relevant log output
No response
@atmonshi Hi! It seems you are trying to use your custom repository plugin.
https://github.com/atmonshi/issue-cluster/blob/main/composer.json#L72
I tried to install plugin from official repo and everything works fine. You need to find answer in your custom repository plugin.
This issue is not related to Filament.
yes but the cluster featuer is not available in the plugin, I opened a PR for it when I encounter this issue
and as I mentioned the curator plugin is just an example tested with other plugins is the same issue
On Mon, Apr 29, 2024 at 1:31 PM Dima Udod @.***> wrote:
@atmonshi https://github.com/atmonshi Hi! It seems you are trying to use your custom repository plugin.
https://github.com/atmonshi/issue-cluster/blob/main/composer.json#L72
I tried to install plugin from official repo and everything works fine. You need to find answer in your custom repository plugin.
This issue is not related to Filament.
— Reply to this email directly, view it on GitHub https://github.com/filamentphp/filament/issues/12532#issuecomment-2082271984, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO4VHD3BVLGDXEKNVKDV7LY7YHP3AVCNFSM6AAAAABG5BSM4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBSGI3TCOJYGQ . You are receiving this because you were mentioned.Message ID: @.***>
Unfortunately I don't think this is possible, as the cluster needs to be read when the routing is registered, and the panel may not be booted at that point so the plugins aren't there