/** * setInstanceConfig * * @param InstanceRoute $instanceRoute instance route * @param XeRequest $request xpressengine request * * @return void */ private function setInstanceConfig(InstanceRoute $instanceRoute, XeRequest $request) { $item = $this->menuHandler->getItem($instanceRoute->instanceId); $menuConfig = $this->menuHandler->getMenuItemTheme($item); if ($request->isMobile()) { $theme = $menuConfig->get('mobileTheme'); } else { $theme = $menuConfig->get('desktopTheme'); } $instanceId = $instanceRoute->instanceId; $module = $instanceRoute->module; $url = $instanceRoute->url; $instanceConfig = InstanceConfig::instance(); $instanceConfig->setTheme($theme); $instanceConfig->setInstanceId($instanceId); $instanceConfig->setModule($module); $instanceConfig->setUrl($url); $themeHandler = $this->themeHandler; $themeHandler->selectTheme($theme); }
/** * moveItem * * @param MenuHandler $handler menu handler * * @return RendererInterface * @throws Exception */ public function moveItem(MenuHandler $handler) { $ordering = Input::get('ordering'); $itemId = Input::get('itemId'); $parentId = Input::get('parent'); XeDB::beginTransaction(); try { $item = $handler->getItem($itemId); /** @var Menu $menu */ if (!($parent = $handler->getItem($parentId))) { $menu = $handler->get($parentId); } else { $menu = $parent->menu; } $old = clone $item; // 이동되기 전 상태의 객체를 구성하기 위해 relation 을 사전에 load $old->ancestors; $item = $handler->moveItem($menu, $item, $parent); $handler->setOrder($item, $ordering); $handler->moveItemConfig($old, $item); $toKey = $handler->permKeyString($item); $toKey = substr($toKey, 0, strrpos($toKey, '.')); $this->permissionMove($handler->permKeyString($old), $toKey); } catch (\Exception $e) { XeDB::rollback(); throw $e; } XeDB::commit(); return XePresenter::makeApi(Input::all()); }