## app binding * xe.widget.parser 으로 바인딩 되어 있음 * 별도의 Fade 는 제공하지 않음 ## 생성자에서 필요한 항목들 * WidgetHandler $widgetHandler - 위젯 핸들러 ## 사용법 ### content 를 위젯 렌더링 html 로 파싱 * content 로 전달하여 내부에 포함된 xml을 파싱하여 * widgetHandler 을 통해서 html 로 렌더링 php $handler->parseXml($content)
Author: XE Developers (developers@xpressengine.com)
 /**
  * Get the evaluated contents of the object.
  *
  * @return \Illuminate\View\View
  */
 public function render()
 {
     $this->setData();
     $this->seo->import($this->data);
     $viewFactory = $this->presenter->getViewFactory();
     $skinView = $this->renderSkin();
     // return only content(Skin)
     if ($this->presenter->getRenderType() == Presenter::RENDER_CONTENT) {
         return $skinView;
     }
     // return popup type
     if ($this->presenter->getRenderType() == Presenter::RENDER_POPUP) {
         $baseTheme = $viewFactory->make(self::$popupHtmlWrapper);
         $baseTheme->content = $skinView;
         return $baseTheme->render();
     }
     $baseTheme = $viewFactory->make(self::$commonHtmlWrapper);
     $viewContent = $this->parser->parseXml($this->renderTheme($skinView)->render());
     $baseTheme->content = $viewContent;
     return $baseTheme->render();
 }
 /**
  * 주어진 위젯박스 code(content)를 파싱하여 반환한다.
  *
  * @param Request      $request
  * @param WidgetParser $parser
  * @param string       $id
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function preview(Request $request, WidgetParser $parser, $id)
 {
     if (\Gate::denies('edit', new Instance('widgetbox.' . $id))) {
         throw new AccessDeniedHttpException();
     }
     $this->validate($request, ['code' => 'required']);
     // widgetbox code
     $code = $request->originInput('code');
     $content = $parser->parseXml($code);
     return XePresenter::makeApi(compact('content'));
 }
 /**
  * setup by code
  *
  * @param Request       $request
  * @param WidgetParser  $widgetParser
  * @param WidgetHandler $widgetHandler
  * @param SkinHandler   $skinHandler
  *
  * @return mixed
  */
 public function setup(Request $request, WidgetParser $widgetParser, WidgetHandler $widgetHandler, SkinHandler $skinHandler)
 {
     $this->validate($request, ['code' => 'required']);
     $code = $request->get('code');
     $inputs = $widgetParser->parseCode($code);
     $widget = array_get($inputs, '@attributes.id');
     $title = array_get($inputs, '@attributes.title', '');
     // widget list
     $widgetList = $widgetHandler->getAll();
     $widgets = [];
     $widgets[''] = '위젯을 선택하세요';
     foreach ($widgetList as $id => $class) {
         $widgets[$id] = $class::getTitle();
     }
     // skin list
     $skins = $skinHandler->getList($widget);
     // widget form
     $widgetForm = $widgetHandler->setup($widget, $inputs);
     // skin form
     $skinConfig = array_get($inputs, 'skin');
     if ($skinConfig && array_has($skinConfig, '@attributes.id')) {
         $skin = array_get($skinConfig, '@attributes.id');
         $skin = $skinHandler->get($skin);
         $skinForm = $skin->renderSetting($skinConfig);
     } else {
         $skinConfig = null;
     }
     return apiRender('widget.setup', compact('widgets', 'widget', 'title', 'skins', 'skin', 'widgetSelector', 'skinSelector', 'widgetForm', 'skinForm'));
 }