NavigationItem: Add method getUniqueName()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-03 10:22:47 +02:00
parent e6a6ae996a
commit 206168672b

View File

@ -325,6 +325,30 @@ class NavigationItem implements IteratorAggregate
return $this; return $this;
} }
/**
* Return this item's name escaped with only ASCII chars and/or digits
*
* @return string
*/
protected function getEscapedName()
{
return preg_replace('~[^a-zA-Z0-9]~', '_', $this->getName());
}
/**
* Return a unique version of this item's name
*
* @return string
*/
public function getUniqueName()
{
if ($this->getParent() === null) {
return 'navigation-' . $this->getEscapedName();
}
return $this->getParent()->getEscapedName() . '-' . $this->getEscapedName();
}
/** /**
* Return this item's name * Return this item's name
* *