mirror of
https://github.com/nextcloud/server.git
synced 2026-06-07 15:53:04 -04:00
fix: move sanitize directly to sanitizeLayout
Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
This commit is contained in:
parent
5a8292fe43
commit
708fa13428
1 changed files with 13 additions and 23 deletions
|
|
@ -31,7 +31,7 @@ class DashboardService {
|
|||
*/
|
||||
public function getLayout(): array {
|
||||
$systemDefault = $this->appConfig->getAppValueString('layout', 'recommendations,spreed,mail,calendar');
|
||||
return $this->sanitizeStringList(
|
||||
return $this->sanitizeLayout(
|
||||
explode(',', $this->userConfig->getValueString($this->userId, 'dashboard', 'layout', $systemDefault)),
|
||||
);
|
||||
}
|
||||
|
|
@ -41,7 +41,18 @@ class DashboardService {
|
|||
* @return list<string>
|
||||
*/
|
||||
public function sanitizeLayout(array $layout): array {
|
||||
return $this->sanitizeStringList($layout);
|
||||
$seen = [];
|
||||
$result = [];
|
||||
foreach ($layout as $value) {
|
||||
if ($value === '' || isset($seen[$value])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$seen[$value] = true;
|
||||
$result[] = $value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,25 +91,4 @@ class DashboardService {
|
|||
|
||||
return $birthdate->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep insertion order while removing empty and duplicate values.
|
||||
*
|
||||
* @param list<string> $values
|
||||
* @return list<string>
|
||||
*/
|
||||
private function sanitizeStringList(array $values): array {
|
||||
$seen = [];
|
||||
$result = [];
|
||||
foreach ($values as $value) {
|
||||
if ($value === '' || isset($seen[$value])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$seen[$value] = true;
|
||||
$result[] = $value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue