Skip to content

Commit a89aefc

Browse files
mykh-hailoAndyScherzinger
authored andcommitted
fix: move sanitize directly to sanitizeLayout
Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
1 parent 1b8e17c commit a89aefc

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

apps/dashboard/lib/Service/DashboardService.php

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(
2929
*/
3030
public function getLayout(): array {
3131
$systemDefault = $this->config->getAppValue('dashboard', 'layout', 'recommendations,spreed,mail,calendar');
32-
return $this->sanitizeStringList(
32+
return $this->sanitizeLayout(
3333
explode(',', $this->config->getUserValue($this->userId, 'dashboard', 'layout', $systemDefault)),
3434
);
3535
}
@@ -39,7 +39,18 @@ public function getLayout(): array {
3939
* @return list<string>
4040
*/
4141
public function sanitizeLayout(array $layout): array {
42-
return $this->sanitizeStringList($layout);
42+
$seen = [];
43+
$result = [];
44+
foreach ($layout as $value) {
45+
if ($value === '' || isset($seen[$value])) {
46+
continue;
47+
}
48+
49+
$seen[$value] = true;
50+
$result[] = $value;
51+
}
52+
53+
return $result;
4354
}
4455

4556
/**
@@ -78,25 +89,4 @@ public function getBirthdate(): string {
7889

7990
return $birthdate->getValue();
8091
}
81-
82-
/**
83-
* Keep insertion order while removing empty and duplicate values.
84-
*
85-
* @param list<string> $values
86-
* @return list<string>
87-
*/
88-
private function sanitizeStringList(array $values): array {
89-
$seen = [];
90-
$result = [];
91-
foreach ($values as $value) {
92-
if ($value === '' || isset($seen[$value])) {
93-
continue;
94-
}
95-
96-
$seen[$value] = true;
97-
$result[] = $value;
98-
}
99-
100-
return $result;
101-
}
10292
}

0 commit comments

Comments
 (0)