Exemplo n.º 1
0
 /**
  * destroy
  *
  * @param MenuRetrieveHandler   $menuHandler       menu handler
  * @param MenuAlterHandler      $menuChanger       menu alter handler
  * @param MenuConfigHandler     $configHandler     menu config handler
  * @param MenuPermissionHandler $permissionHandler menu permission handler
  * @param string                $menuId            to delete menu entity object id
  *
  * @return RedirectResponse
  */
 public function destroy(MenuRetrieveHandler $menuHandler, MenuAlterHandler $menuChanger, MenuConfigHandler $configHandler, MenuPermissionHandler $permissionHandler, $menuId)
 {
     XeDB::beginTransaction();
     try {
         $menu = $menuHandler->getMenu($menuId);
         $menuChanger->removeMenu($menu);
         $configHandler->deleteMenuTheme($menu);
         $permissionHandler->deleteMenuPermission($menu);
     } catch (Exception $e) {
         XeDB::rollback();
         return Redirect::back()->with('alert', ['type' => 'danger', 'message' => $e->getMessage()]);
     }
     XeDB::commit();
     return Redirect::route('settings.menu.index')->with('alert', ['type' => 'success', 'message' => 'Menu deleted']);
 }
 /**
  * testDeleteMenuTheme
  *
  * @return void
  */
 public function testDeleteMenuTheme()
 {
     // MenuEntity $menu
     $configManager = $this->configManager;
     $themeHandler = $this->themeHandler;
     $configManager->shouldReceive('removeByName')->andReturn();
     $dummyMenu = new MenuEntity(['id' => 'testMenu', 'title' => 'testTitle', 'description' => 'testDescription'], new TreeCollection([new MenuItem(['id' => 'testMenu'])]), new Collection());
     $menuConfigHandler = new MenuConfigHandler($configManager, $themeHandler);
     $menuConfigHandler->deleteMenuTheme($dummyMenu);
 }