Example #1
0
 /**
  * Set a valid title and href
  *
  * @test
  * @return void
  */
 public function isMenuItemValidSetValidHrefAndTitleExpectTrue()
 {
     $menuItem = new MenuItem();
     $menuItem->setTitle('husel')->setHref('husel');
     $isValid = $menuItem->isValid($menuItem);
     $this->assertTrue($isValid);
 }
Example #2
0
 /**
  * Validation
  *
  * @param MenuItem $menuItem The menuItem to validate
  *
  * @return bool
  */
 public function isValid(MenuItem $menuItem)
 {
     if ($menuItem->getHref() !== '' && $menuItem->getTitle() !== '') {
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * Adds a new menuItem
  *
  * @param MenuItem $menuItem The menuItem to add to the menu
  *
  * @throws \InvalidArgumentException In case a menuItem is not valid
  *
  * @return void
  */
 public function addMenuItem(MenuItem $menuItem)
 {
     if (!$menuItem->isValid($menuItem)) {
         throw new \InvalidArgumentException('MenuItem "' . $menuItem->getTitle() . '" is not valid', 1442236317);
     }
     // @todo implement sorting of menu items
     // @todo maybe even things like spacers/sections?
     $this->menuItems[] = clone $menuItem;
 }