diff --git a/apps/dashboard/lib/Service/DashboardService.php b/apps/dashboard/lib/Service/DashboardService.php index 46c46f54eb0..c94617d6941 100644 --- a/apps/dashboard/lib/Service/DashboardService.php +++ b/apps/dashboard/lib/Service/DashboardService.php @@ -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 */ 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 $values - * @return list - */ - 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; - } }