mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
Navigation: Peform a case-insensitive search when merging items
refs #5600
This commit is contained in:
parent
0c3c38a2ef
commit
b2a0f1b9c2
@ -318,6 +318,28 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
|
|||||||
return $a->getPriority() > $b->getPriority() ? 1 : -1;
|
return $a->getPriority() > $b->getPriority() ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to find and return a item with the given or a similar name
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return NavigationItem
|
||||||
|
*/
|
||||||
|
protected function findItem($name)
|
||||||
|
{
|
||||||
|
$item = $this->getItem($name);
|
||||||
|
if ($item !== null) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
$loweredName = strtolower($name);
|
||||||
|
foreach ($this->getItems() as $item) {
|
||||||
|
if (strtolower($item->getName()) === $loweredName) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge this navigation with the given one
|
* Merge this navigation with the given one
|
||||||
*
|
*
|
||||||
@ -331,7 +353,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
|
|||||||
{
|
{
|
||||||
foreach ($navigation as $item) {
|
foreach ($navigation as $item) {
|
||||||
/** @var $item NavigationItem */
|
/** @var $item NavigationItem */
|
||||||
if (($existingItem = $this->getItem($item->getName())) !== null) {
|
if (($existingItem = $this->findItem($item->getName())) !== null) {
|
||||||
if ($existingItem->conflictsWith($item)) {
|
if ($existingItem->conflictsWith($item)) {
|
||||||
$name = $item->getName();
|
$name = $item->getName();
|
||||||
do {
|
do {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user