Skip to content

Commit

Permalink
DashboardEntries: Perform case-insensitive key checks when searching …
Browse files Browse the repository at this point in the history
…for dashboard entry
  • Loading branch information
yhabteab committed Jun 10, 2022
1 parent 267a480 commit b6958b1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions library/Icinga/Web/Dashboard/Common/DashboardEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public function getEntry(string $name)
throw new ProgrammingError('Trying to retrieve invalid dashboard entry "%s"', $name);
}

return $this->dashboards[$name];
return $this->dashboards[strtolower($name)];
}

public function hasEntry(string $name)
{
return array_key_exists($name, $this->dashboards);
return array_key_exists(strtolower($name), $this->dashboards);
}

public function getEntries()
Expand All @@ -45,7 +45,7 @@ public function getEntries()

public function setEntries(array $entries)
{
$this->dashboards = $entries;
$this->dashboards = array_change_key_case($entries);

return $this;
}
Expand All @@ -55,7 +55,7 @@ public function addEntry(BaseDashboard $dashboard)
if ($this->hasEntry($dashboard->getName())) {
$this->getEntry($dashboard->getName())->setProperties($dashboard->toArray(false));
} else {
$this->dashboards[$dashboard->getName()] = $dashboard;
$this->dashboards[strtolower($dashboard->getName())] = $dashboard;
}

return $this;
Expand All @@ -65,7 +65,7 @@ public function getEntryKeyTitleArr()
{
$dashboards = [];
foreach ($this->getEntries() as $dashboard) {
$dashboards[$dashboard->getName()] = $dashboard->getTitle();
$dashboards[ucwords($dashboard->getName())] = $dashboard->getTitle();
}

return $dashboards;
Expand Down Expand Up @@ -104,7 +104,7 @@ public function unsetEntry(BaseDashboard $dashboard)
throw new ProgrammingError('Trying to unset an invalid Dashboard entry: "%s"', $dashboard->getName());
}

unset($this->dashboards[$dashboard->getName()]);
unset($this->dashboards[strtolower($dashboard->getName())]);

return $this;
}
Expand Down

0 comments on commit b6958b1

Please sign in to comment.