Xpressengine\Menu\MenuHandler::setMenuTheme PHP Method

setMenuTheme() public method

Set menu config consisting of theme identifiers
public setMenuTheme ( Menu $menu, string $desktopTheme, string $mobileTheme ) : void
$menu Xpressengine\Menu\Models\Menu menu instance
$desktopTheme string theme id
$mobileTheme string theme id
return void
    public function setMenuTheme(Menu $menu, $desktopTheme, $mobileTheme)
    {
        $this->configs->add($this->menuKeyString($menu->getKey()), ['desktopTheme' => $desktopTheme, 'mobileTheme' => $mobileTheme]);
    }

Usage Example

示例#1
0
 /**
  * store
  * 새로운 메뉴 생성을 처리하는 메소드
  *
  * @param MenuHandler $handler menu handler
  *
  * @return mixed
  * @throws Exception
  */
 public function store(MenuHandler $handler)
 {
     $desktopTheme = Input::get('theme_desktop');
     $mobileTheme = Input::get('theme_mobile');
     $rules = ['menuTitle' => 'required', 'theme_desktop' => 'required', 'theme_mobile' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         Input::flash();
         return Redirect::back()->with('alert', ['type' => 'danger', 'message' => $validator->messages()]);
     }
     XeDB::beginTransaction();
     try {
         $menu = $handler->create(['title' => Input::get('menuTitle'), 'description' => Input::get('menuDescription'), 'siteKey' => Input::get('siteKey')]);
         $handler->setMenuTheme($menu, $desktopTheme, $mobileTheme);
         $this->permissionRegisterGrant($menu->getKey(), $handler->getDefaultGrant());
     } catch (Exception $e) {
         XeDB::rollback();
         Input::flash();
         return Redirect::back()->with('alert', ['type' => 'danger', 'message' => $e->getMessage()]);
     }
     XeDB::commit();
     return Redirect::route('settings.menu.index');
 }