You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remeber $this->fields is still [] because no field is created yet ¯_(ツ)_/¯
Unfortunately if it comes really from a plugin, Craft will do the following
// If it comes from a plugin, make sure the plugin is installed$pluginsService = Craft::$app->getPlugins();
$pluginHandle = $pluginsService->getPluginHandleByClass($class);
if ($pluginHandle !== null && !$pluginsService->isPluginEnabled($pluginHandle)) {
/** * Returns whether a given plugin is installed and enabled. * * @param string $handle The plugin handle * @return bool */publicfunctionisPluginEnabled(string$handle): bool
{
$this->loadPlugins();
returnisset($this->_enabledPluginInfo[$handle]);
}
The function $this->loadPlugins(); is the key point here.... because it does what the name let's you think.. it loads all plugins and trigger the event
if ($this->hasEventHandlers(self::EVENT_AFTER_LOAD_PLUGINS)) {
$this->trigger(self::EVENT_AFTER_LOAD_PLUGINS);
}
Remeber when I told $this->fields is still an empty array? That's even now the case when your event is triggert
So $fields = Craft::$app->getFields()->getAllFields(); returns an empty array and no field will be marked with a wheel.
Currently my work-around is to copy your code in my custom module and run it again, but it would be easier to call the function doIt twice
The text was updated successfully, but these errors were encountered:
I don't believe this is relevant anymore since I moved the Craft::$app->getUser()->getIsAdmin() query into a EVENT_AFTER_LOAD_PLUGINS handler w/ CP Field Inspect 1.0.7. Closing.
I found a strange issue or at least a very edge case scenario in your plugin.
When there is an internal call in Craft for
and there are no fields yet, it will fetch all of them from the DB and loop those results to populate fields.
So it will call
and it does
That function tries to validate it
Remeber
$this->fields
is still[]
because no field is created yet ¯_(ツ)_/¯Unfortunately if it comes really from a plugin, Craft will do the following
The function
$this->loadPlugins();
is the key point here.... because it does what the name let's you think.. it loads all plugins and trigger the eventRemeber when I told
$this->fields
is still an empty array? That's even now the case when your event is triggertSo
$fields = Craft::$app->getFields()->getAllFields();
returns an empty array and no field will be marked with a wheel.Currently my work-around is to copy your code in my custom module and run it again, but it would be easier to call the function
doIt
twiceThe text was updated successfully, but these errors were encountered: