-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PluginInterface::config() #11039
PluginInterface::config() #11039
Conversation
Nice. Curiously, why not place these overrides in each plugin's config file? (Seems like it might be slightly more tidy to keep container overrides close in code to plugin settings. The structure of the plugin config file would need to change slightly, perhaps by moving settings overrides into an explicit
Not questioning the merit of this change at all; I can definitely imagine use cases for plugins opening up the container to customization... Just curious about the considerations that led you towards this particular implementation. Cases for overriding plugin components may be relatively rare, but it still seems like this |
Craft CMS just hit the FC stage; isn't this a new feature? Also agree with @michaelrog 's comments on the structure. |
To be clear,
The case for configuring a plugin via Also consider that traditional plugin settings end up in the project config, even if configured via the plugin’s
That’s the inspiration for this. Plugins end up getting registered as modules on the app, but they are not configurable via |
Cool — Thanks for explaining; makes sense! 👍🏼 |
Curiously, are yall planning to deprecate the |
We’ve sortof soft-deprecated it – there’s not been any mention of it in the plugin guide for quite a while – because the disconnect of configuring your PHP module via a JSON file was a little awkward (not to mention annoying/confusing you need to |
@khalwat I don’t think each individual plugin should have its own proprietary way of making itself configurable. |
@brandonkelly wasn't suggesting that. Just noting the config format of: 'params' => [ ... ],
'components' => [
// ...
], Feels weird for it to be so deeply nested in: return [
'components' => [
'plugins' => [
'pluginConfigs' => [
'my-plugin' => [
'components' => [
'myComponent' => [
'myProperty' => 'foo',
// ...
],
],
],
],
],
],
]; ...but you explained the reasoning, so away we go. |
Well it’s the same format; just nested further down, and I didn’t include You could still give each plugin its own config file and require them from return [
'components' => [
'plugins' => [
'pluginConfigs' => [
'my-plugin' => require(__DIR__ . '/plugin-configs/my-plugin.php'),
],
],
],
]; (Just don’t put the plugin config files directly in the |
…r overriding via plugin config ([#1989](craftcms/cms#1989)) ([#11039](craftcms/cms#11039))
This adds a new static
config()
method tocraft\base\PluginInterface
, giving plugins a way to define their configuration.Plugins that have their own additional components (e.g. services) should start using this to define them:
Doing that enables projects to customize the components as needed, by overriding
craft\services\Plugins::$pluginConfigs
inconfig/app.php
: