Skip to content

Commit

Permalink
Refactor get call outside of loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 10, 2024
1 parent a49a4c7 commit 741b1a4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/VuFindTheme/src/VuFindTheme/Initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,15 @@ protected function getThemeOptions($currentTheme)
if (isset($this->config->selectable_themes)) {
$parts = explode(',', $this->config->selectable_themes);
$foundSelected = false;
$uiCookie = $this->cookieManager->get('ui');
foreach ($parts as $part) {
$subparts = explode(':', $part);
$name = trim($subparts[0]);
$desc = isset($subparts[1]) ? trim($subparts[1]) : '';
$desc = empty($desc) ? $name : $desc;
// Easiest and most accurate way to pick a selected theme is to check
// if the name matches the current value of the ui cookie:
$selected = $this->cookieManager->get('ui') === $name;
$selected = $uiCookie === $name;
$foundSelected = $foundSelected || $selected;
if (!empty($name)) {
$options[] = compact('name', 'desc', 'selected');
Expand Down

0 comments on commit 741b1a4

Please sign in to comment.