mirror of
https://github.com/flarum/framework.git
synced 2025-01-20 03:02:45 +08:00
Add backwards compatibility layer for mail drivers
Support the old format (a simple list of available fields), in addition to the new format (a map from field names to their types + metadata). This will be removed after beta.12 is released.
This commit is contained in:
parent
1170d5c2cf
commit
1e7fbf1ed9
|
@ -33,10 +33,20 @@ class MailDriverSerializer extends AbstractSerializer
|
|||
);
|
||||
}
|
||||
|
||||
$driver = $driver['driver'];
|
||||
$settings = $driver['driver']->availableSettings();
|
||||
|
||||
if (key($settings) === 0) {
|
||||
// BACKWARDS COMPATIBILITY: Support a simple list of fields (without
|
||||
// type or additional metadata).
|
||||
// Turns ["f1", "f2"] into {"f1": "", "f2": ""}
|
||||
// @deprecated since 0.1.0-beta.12
|
||||
$settings = array_reduce($settings, function ($memo, $key) {
|
||||
return [$key => ''] + $memo;
|
||||
}, []);
|
||||
}
|
||||
|
||||
return [
|
||||
'fields' => $driver->availableSettings(),
|
||||
'fields' => $settings,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user