Navigation: Peform a case-insensitive search when merging items

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-04 14:17:16 +02:00
parent 0c3c38a2ef
commit b2a0f1b9c2
1 changed files with 23 additions and 1 deletions

View File

@ -318,6 +318,28 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
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
*
@ -331,7 +353,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
{
foreach ($navigation as $item) {
/** @var $item NavigationItem */
if (($existingItem = $this->getItem($item->getName())) !== null) {
if (($existingItem = $this->findItem($item->getName())) !== null) {
if ($existingItem->conflictsWith($item)) {
$name = $item->getName();
do {