improve color chooser and name validation (#2622)

This commit is contained in:
Kevin Papst
2021-06-25 16:35:16 +02:00
committed by GitHub
parent 0d5e0b3e80
commit 3d1fba650b
11 changed files with 77 additions and 40 deletions

View File

@@ -367,32 +367,13 @@ class SystemConfiguration implements SystemBundleConfiguration
return (int) $this->find('theme.autocomplete_chars');
}
public function getThemeColorChoices(): ?array
public function getThemeColorChoices(): ?string
{
$config = $this->find('theme.color_choices');
if (empty($config)) {
return null;
}
$config = explode(',', $config);
$colors = [];
foreach ($config as $item) {
if (empty($item)) {
continue;
}
$item = explode('|', $item);
$key = $item[0];
$value = $key;
if (\count($item) > 1) {
$value = $item[1];
}
if (empty($key)) {
$key = $value;
}
$colors[$key] = $value;
if (!empty($config)) {
return $config;
}
return array_unique($colors);
return $this->default('theme.color_choices');
}
}