NavigationItemForm: Strip the current base url from an item's url

This commit is contained in:
Johannes Meyer 2015-09-30 15:37:15 +02:00
parent eef4322188
commit 16cdd76c9e
1 changed files with 17 additions and 0 deletions

View File

@ -4,6 +4,7 @@
namespace Icinga\Forms\Navigation;
use Icinga\Web\Form;
use Icinga\Web\Url;
class NavigationItemForm extends Form
{
@ -71,4 +72,20 @@ class NavigationItemForm extends Form
)
);
}
/**
* {@inheritdoc}
*/
public function getValues($suppressArrayNotation = false)
{
$values = parent::getValues($suppressArrayNotation);
if (isset($values['url']) && $values['url']) {
$url = Url::fromPath($values['url']);
if (! $url->isExternal() && ($relativePath = $url->getRelativeUrl())) {
$values['url'] = $relativePath;
}
}
return $values;
}
}