## App binding * xe.presenter 로 바인딩 되어 있음 * Presenter facade 제공 ## Interception ## 사용법 ### 스킨 사용 등록 php $presenter = app('xe.presenter'); 사용자 스킨 사용 $presenter->setSkin('parent-key'); 관리자 스킨 사용 $presenter->setSettingsSkin('parent-key'); ### Html 형식만 지원 php public controllerMethodName() { ... 생략 ... return Presenter::make('skin.view.name'); } ### Api(json) 형식만 지원 할 경우 php public controllerMethodName() { ... 생략 ... return Presenter::makeApi(['data']); } ### 모든 형식을 지원 할 경우 php public controllerMethodName() { ... 생략 ... return Presenter::makeAll('skin.view.name'); }
Author: XE Team (developers) (developers@xpressengine.com)
 /**
  * change instance id
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function copy()
 {
     $documentIds = Input::get('id');
     $documentIds = is_array($documentIds) ? $documentIds : [$documentIds];
     $instanceId = Input::get('instanceId');
     foreach ($documentIds as $id) {
         XeDB::beginTransaction();
         $this->handler->copy($id, $this->configHandler->get($instanceId), (new Keygen())->generate());
         XeDB::commit();
     }
     return $this->presenter->makeApi([]);
 }
 /**
  * render theme
  *
  * @param \Illuminate\View\View $skinView skin view
  * @return \Illuminate\View\View
  */
 public function renderTheme($skinView)
 {
     $themeView = $skinView;
     $themeHandler = $this->presenter->getThemeHandler();
     // get instance theme
     /** @var ThemeEntity $theme */
     $theme = $themeHandler->getSelectedTheme();
     // get site default theme
     if ($theme === null) {
         $themeHandler->selectSiteTheme();
         $theme = $themeHandler->getSelectedTheme();
     }
     if ($theme !== null) {
         // apply theme
         $themeView = $theme->render();
         $themeView->content = $skinView;
     }
     return $themeView;
 }
 /**
  * move to copy
  *
  * @return \Illuminate\Http\RedirectResponse|Redirect
  */
 public function copy(Request $request)
 {
     $documentIds = $request->get('id');
     $documentIds = is_array($documentIds) ? $documentIds : [$documentIds];
     $instanceId = $request->get('instanceId');
     $config = $this->configHandler->get($instanceId);
     if ($config === null) {
         throw new NotFoundConfigHttpException(['instanceId' => $instanceId]);
     }
     $items = Board::find($documentIds);
     foreach ($items as $item) {
         $this->handler->setModelConfig($item, $this->configHandler->get($item->instanceId));
         $user = new Guest();
         if ($item->userId != '') {
             $user = User::find($item->userId);
         }
         $this->handler->copy($item, $user, $config);
     }
     Session::flash('alert', ['type' => 'success', 'message' => xe_trans('xe::processed')]);
     return $this->presenter->makeApi([]);
 }
 /**
  * Get the instance as an array.
  *
  * @return array
  */
 public function toArray()
 {
     return $this->presenter->getData();
 }
 /**
  * test get invalid renderer
  *
  * @expectedException \Xpressengine\Presenter\Exceptions\InvalidRendererException
  * @return void
  */
 public function testGetInvalidRenderer()
 {
     $request = $this->request;
     $view = $this->view;
     $theme = $this->theme;
     $skin = $this->skin;
     $settings = $this->settings;
     $instanceConfig = $this->instanceConfig;
     $presenter = new Presenter($view, $request, $theme, $skin, $settings, $instanceConfig);
     $htmlRenderer = m::mock('HtmlRenderer');
     $presenter->register('html', function ($presenter) use($htmlRenderer) {
         return new $htmlRenderer($presenter);
     });
     $request->shouldReceive('format')->once()->andReturn('html');
     $this->invokeMethod($presenter, 'get');
 }
 /**
  * return json format string
  *
  * @param int $options options
  * @return string
  */
 public function toJson($options = 0)
 {
     $this->data = $this->convert($this->presenter->getData());
     return json_encode($this->data);
 }