Skip to content

Commit a08aa1d

Browse files
committed
Add support for returning BaseConfig objects in plugin settings files
1 parent 2c0e83f commit a08aa1d

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
### Changed
99
- Edit Asset pages now show the “View” button for all file types, not just images, PDFs, and text files. ([#11936](https://github.com/craftcms/cms/issues/11936))
10+
- Plugins’ config files can now return the plugins’ settings objects so long as they extend `craft\config\BaseConfig`.
1011

1112
### Fixed
1213
- Fixed a bug where image transforms weren’t always getting applied properly to all animation frames. ([#11937](https://github.com/craftcms/cms/pull/11937))

src/services/Plugins.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,9 +929,11 @@ public function createPlugin(string $handle, ?array $info = null): ?PluginInterf
929929
$config['edition'] = reset($editions);
930930
}
931931

932+
// todo: Add support for passing a settings model directly into Plugin::setSettings()
933+
// so we don't have to reinstantiate the object if a BaseConfig object was returned from getConfigFromFile()
932934
$settings = array_merge(
933935
$info['settings'] ?? [],
934-
Craft::$app->getConfig()->getConfigFromFile($handle)
936+
(array)Craft::$app->getConfig()->getConfigFromFile($handle)
935937
);
936938

937939
if ($settings !== []) {

0 commit comments

Comments
 (0)