Skip to content
Snippets Groups Projects
Commit 8ca38526 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #3578

Closes #3578

Merge request studip/studip!2474
parent 4325b052
No related branches found
No related tags found
No related merge requests found
...@@ -352,38 +352,27 @@ class Navigation implements IteratorAggregate ...@@ -352,38 +352,27 @@ class Navigation implements IteratorAggregate
} }
/** /**
* Set the image of this navigation item. Additional HTML * Set the image of this navigation item.
* attributes can be passed using the $options parameter
* (like 'style' or 'onclick').
* *
* @param Icon $image an instance of class Icon depicting this item * @param \Icon|null $image an instance of class Icon depicting this item
* @param array $link_attributes additional link attributes * or null to remove the image
*/ */
public function setImage(\Icon $image = null, $linkAttributes = []) public function setImage(?\Icon $image)
{ {
$this->image = $image; $this->image = $image;
$this->link_attributes = array_merge(
$this->link_attributes,
$linkAttributes
);
} }
/** /**
* Set the image for the active state of this navigation item. * Set the image for the active state of this navigation item.
* If no active image is set, the normal image is used for the * If no active image is set, the normal image is used for the
* active state. Additional HTML attributes can be passed using * active state.
* the $options parameter (like 'style' or 'onclick').
* *
* @param Icon $image an instance of class Icon depicting this item * @param \Icon|null $image an instance of class Icon depicting this item
* @param array $link_attributes additional link attributes * or null to remove the image
*/ */
public function setActiveImage(\Icon $image = null, $linkAttributes = []) public function setActiveImage(?\Icon $image)
{ {
$this->active_image = $image; $this->active_image = $image;
$this->link_attributes = array_merge(
$this->link_attributes,
$linkAttributes
);
} }
/** /**
......
...@@ -44,14 +44,12 @@ class NavigationTest extends \Codeception\Test\Unit ...@@ -44,14 +44,12 @@ class NavigationTest extends \Codeception\Test\Unit
$navigation = new Navigation('test', 'foo.php'); $navigation = new Navigation('test', 'foo.php');
$this->assertNull($navigation->getImage()); $this->assertNull($navigation->getImage());
$icon = Icon::create('foo', 'clickable'); $icon = Icon::create('foo', Icon::ROLE_CLICKABLE);
$link_attrs = ['alt' => 'foo'];
$navigation->setImage($icon, $link_attrs); $navigation->setImage($icon);
$this->assertTrue($navigation->isVisible(true)); $this->assertTrue($navigation->isVisible(true));
$this->assertEquals($icon, $navigation->getImage()); $this->assertEquals($icon, $navigation->getImage());
$this->assertEquals($link_attrs, $navigation->getLinkAttributes());
} }
public function testActiveImage () public function testActiveImage ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment