/**
  * Adds a menu to the registry
  *
  * @param Menu $menu Menu object to add to the menuRegistry
  *
  * @throws \InvalidArgumentException In case a menu is not valid
  *
  * @return void
  */
 public function addMenu(Menu $menu)
 {
     if (!$menu->isValid($menu)) {
         throw new \InvalidArgumentException('Menu "' . $menu->getIdentifier() . '" is not valid', 1442236362);
     }
     $this->menus[$menu->getIdentifier()] = clone $menu;
 }
Exemple #2
0
 /**
  * Set a valid menu
  *
  * @test
  * @return void
  */
 public function makeMenuAllGoodExpectTrue()
 {
     $menuRegistry = new MenuRegistry();
     $result = $menuRegistry->makeMenu()->setLabel('MenuLabel')->setIdentifier('MenuIdent');
     $expected = new Menu();
     $expected->setIdentifier('MenuIdent');
     $expected->setLabel('MenuLabel');
     $this->assertEquals($expected, $result);
 }
Exemple #3
0
 /**
  * Validation function
  *
  * @param Menu $menu The menu to validate
  *
  * @return bool
  */
 public function isValid(Menu $menu)
 {
     return trim($menu->getIdentifier()) !== '';
 }