-
Notifications
You must be signed in to change notification settings - Fork 6
/
ThemeSettingsConfig.php
54 lines (48 loc) · 1.58 KB
/
ThemeSettingsConfig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @file
* Contains \Drupal\fett\Theme\ThemeSettingsConfig.
*/
namespace Drupal\fett\Theme;
use Drupal\Core\Config\Config;
use Drupal\Component\Utility\Unicode;
class ThemeSettingsConfig {
/**
* Set config for theme Extension settings.
* @param array $values
* @param \Drupal\Core\Config\Config $config
*/
public function settingsExtensionsConvertToConfig(array $values, Config $config) {
foreach ($values as $key => $value) {
if (substr($key, 0, 9) == 'settings_') {
$config_key = Unicode::substr($key, 9);
$config->set('settings.' . $config_key, $value);
}
}
$config->save();
}
/**
* Set config for theme Layout settings.
* @param array $values
* @param \Drupal\Core\Config\Config $config
*/
public function settingsLayoutConvertToConfig(array $values, Config $config) {
foreach ($values as $key => $value) {
if (substr($key, 0, 9) == 'settings_') {
$config_key = Unicode::substr($key, 9);
$config->set('settings.' . $config_key, $value);
}
// Delete suggestions config settings. Do not remove all the suggestions
// setting because later on if the suggestion is recreated there will be
// settings for it already which is kind of nice for the user should they
// accidentally delete a suggestion.
if (substr($key, 0, 18) == 'delete_suggestion_') {
$delete_suggestion_key = 'settings.suggestion_' . Unicode::substr($key, 18);
if ($value == 1) {
$config->clear($delete_suggestion_key, $value);
}
}
}
$config->save();
}
}