## app binding * xe.site 으로 바인딩 되어 있음 * XeSite Facade 제공 ## 사용법 ### 현재의 Site 객체를 획득 php XeSite::getCurrentSite() ### 현재의 Site 객체를 지정 php XeSite::setCurrentSite(Site $site) ### 현재의 SiteKey 획득 * 현재 사이트 객체에서 사이트 키를 가져옴. * 편의를 위해서 제공 php XeSite::getCurrentSiteKey() ### Site 의 ConfigEntity 획득 * siteKey 에 해당하는 설정 정보 가져옴 * siteKey 를 전달하지 않는 경우에는 defaultSiteKey 가 적용됨 php XeSite::getSiteConfig($siteKey = null) ### Site 의 ConfigEntity 업데이트 * siteKey 에 해당하는 ConfigEntity 수정 php XeSite::putSiteConfig(ConfigEntity $config)
저자: XE Developers (developers@xpressengine.com)
예제 #1
0
 public function updateSetting(SiteHandler $siteHandler, ThemeHandler $themeHandler, Request $request)
 {
     $newConfig = $request->only(['site_title', 'favicon']);
     $oldConfig = $siteHandler->getSiteConfig();
     /* resolve site_title */
     $oldConfig['site_title'] = $newConfig['site_title'];
     /* resolve favicon */
     $uploaded = array_get($newConfig, 'favicon');
     if ($uploaded !== null) {
         // remove old favicon file
         if ($oldId = $oldConfig->get('favicon.id')) {
             $oldId = $oldConfig->get('favicon.id');
             if ($oldId !== null) {
                 $oldFile = File::find($oldId);
                 if ($oldFile !== null) {
                     app('xe.storage')->remove($oldFile);
                 }
             }
         }
         $saved = app('xe.storage')->upload($uploaded, 'filebox');
         $favicon = ['id' => $saved->id, 'filename' => $saved->clientname];
         $media = app('xe.media');
         $mediaFile = null;
         if ($media->is($saved)) {
             $mediaFile = $media->make($saved);
             $favicon['path'] = $mediaFile->url();
         }
         $oldConfig['favicon'] = $favicon;
     }
     $siteHandler->putSiteConfig($oldConfig);
     // resolve index instance
     $indexInstance = $request->get('indexInstance');
     $siteHandler->setHomeInstanceId($indexInstance);
     return \Redirect::back()->with('alert', ['type' => 'success', 'message' => '저장되었습니다.']);
 }
예제 #2
0
 public function testPut()
 {
     list($configs) = $this->getMocks();
     $instance = new SiteHandler($configs);
     $mockSite = m::mock('Xpressengine\\Site\\Site');
     $mockSite->shouldReceive('isDirty')->andReturn(true);
     $mockSite->shouldReceive('save')->once();
     $instance->put($mockSite);
 }
 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'));
 }
예제 #4
0
 /**
  * getHomeInstanceRoute
  *
  * @return InstanceRoute
  */
 private function getHomeInstanceRoute()
 {
     if (static::$homeInstanceRoute === null) {
         $homeInstanceId = $this->siteHandler->getHomeInstanceId();
         $instanceRoute = $this->routeRepo->findByInstanceId($homeInstanceId);
         static::$homeInstanceRoute = $instanceRoute;
         return $instanceRoute;
     } else {
         return static::$homeInstanceRoute;
     }
 }
 /**
  * getHomeInstanceRoute
  *
  * @return InstanceRoute
  */
 private function getHomeInstanceRoute()
 {
     /**
      * @var $instanceRouter InstanceRouteHandler
      **/
     if (static::$homeInstanceRoute === null) {
         $instanceRouter = $this->routeHandler;
         $homeInstanceId = $this->siteHandler->getHomeInstanceId();
         $instanceRoute = $instanceRouter->getByInstanceId($homeInstanceId);
         static::$homeInstanceRoute = $instanceRoute;
         return $instanceRoute;
     } else {
         return static::$homeInstanceRoute;
     }
 }
예제 #6
0
 /**
  * setHome
  *
  * @param SiteHandler $siteHandler site handler
  *
  * @return RendererInterface
  *
  */
 public function setHome(SiteHandler $siteHandler)
 {
     $itemId = Input::get('itemId');
     $siteHandler->setHomeInstanceId($itemId);
     return XePresenter::makeApi([$itemId]);
 }