NavigationItemRenderer: Add option $target

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-03 13:36:34 +02:00
parent 67dee62c57
commit 16ece09b0a
1 changed files with 36 additions and 5 deletions

View File

@ -20,6 +20,13 @@ class NavigationItemRenderer
*/
protected $view;
/**
* The link target
*
* @var string
*/
protected $target;
/**
* Create a new NavigationItemRenderer
*
@ -49,6 +56,19 @@ class NavigationItemRenderer
}
}
/**
* Set the view
*
* @param View $view
*
* @return $this
*/
public function setView(View $view)
{
$this->view = $view;
return $this;
}
/**
* Return the view
*
@ -64,18 +84,28 @@ class NavigationItemRenderer
}
/**
* Set the view
* Set the link target
*
* @param View $view
* @param string $target
*
* @return $this
*/
public function setView(View $view)
public function setTarget($target)
{
$this->view = $view;
$this->target = $target;
return $this;
}
/**
* Return the link target
*
* @return string
*/
public function getTarget()
{
return $this->target;
}
/**
* Render the given navigation item as HTML anchor
*
@ -92,9 +122,10 @@ class NavigationItemRenderer
if (($url = $item->getUrl()) !== null) {
$content = sprintf(
'<a%s href="%s">%s</a>',
'<a%s href="%s"%s>%s</a>',
$this->view()->propertiesToString($item->getAttributes()),
$this->view()->url($url, $item->getUrlParameters()),
$this->target ? ' target="' . $this->view()->escape($this->target) . '"' : '',
$label
);
} else {