public function editSetting(MenuRetrieveHandler $menuHandler, SiteHandler $siteHandler, ThemeHandler $themeHandler)
 {
     $config = app('xe.site')->getSiteConfig();
     $siteKey = $siteHandler->getCurrentSiteKey();
     $indexInstance = $siteHandler->getHomeInstanceId();
     $menus = $menuHandler->getAllMenu($siteKey);
     $selectedTheme = $themeHandler->getSiteThemeId();
     return \Presenter::make('settings.setting', compact('config', 'selectedTheme', 'menus', 'indexInstance'));
 }
 /**
  * moveItem
  *
  * @param MenuRetrieveHandler   $menuRetrieveHandler menu handler
  * @param MenuAlterHandler      $menuChanger         menu alter handler
  * @param MenuConfigHandler     $configHandler       menu config handler
  * @param MenuPermissionHandler $permissionHandler   menu permission handler
  *
  * @return RendererInterface
  * @throws Exception
  */
 public function moveItem(MenuRetrieveHandler $menuRetrieveHandler, MenuAlterHandler $menuChanger, MenuConfigHandler $configHandler, MenuPermissionHandler $permissionHandler)
 {
     $ordering = Request::get('ordering');
     $itemId = Request::get('itemId');
     $parentId = Request::get('parent');
     XeDB::beginTransaction();
     try {
         $item = $menuRetrieveHandler->getItem($itemId);
         $movedItem = $menuChanger->moveItem($item, $parentId);
         $menuChanger->setOrder($item, $ordering);
         $configHandler->moveItemConfig($item, $movedItem);
         $permissionHandler->moveItemPermission($item, $movedItem);
     } catch (\Exception $e) {
         XeDB::rollback();
         throw $e;
     }
     XeDB::commit();
     return Presenter::makeApi(\Request::all());
 }
 /**
  * testGetItem
  *
  * @return void
  */
 public function testGetItem()
 {
     $menuRepo = $this->menuRepository;
     $typeHandler = $this->typeHandler;
     $permissionHandler = $this->menuPermissionHandler;
     $cacheHandler = $this->cacheHandler;
     $menuPermission = $this->menuPermission;
     $dummyMenuItem = new MenuItem(['id' => 'testMenuItem1']);
     $dummyMenu1 = new MenuEntity(['id' => 'main', 'title' => 'testTitle1', 'description' => 'testDescription'], new TreeCollection(['testMenuItem1' => $dummyMenuItem]));
     $menuHandler = new MenuRetrieveHandler($menuRepo, $typeHandler, $permissionHandler, $cacheHandler);
     $menuRepo->shouldReceive('findItem')->andReturn($dummyMenuItem);
     $menuRepo->shouldReceive('findMenu')->andReturn($dummyMenu1);
     $menuRepo->shouldReceive('getMenuIdByItem')->andReturn($dummyMenu1);
     $cacheHandler->shouldReceive('isExistCachedMenu')->andReturn(true);
     $cacheHandler->shouldReceive('getCachedMenu')->with('main')->andReturn($dummyMenu1);
     $cacheHandler->shouldReceive('getMenuMap')->andReturn(['testMenuItem1' => 'main']);
     $permissionHandler->shouldReceive('getMenuPermissions')->andReturn(['testMenuItem1' => $menuPermission, '' => $menuPermission]);
     $menuItem = $menuHandler->getItem('testMenuItem1');
     $this->assertEquals($dummyMenuItem, $menuItem);
 }