/** * Render widget, query string 't' indicates the name of the widget */ public function actionWidget($id = '') { $widgetType = \Yii::$app->request->get('t', ''); $params = \Yii::$app->params; $color = $params['micrositeDefaultColor']; $data = null; if (empty($widgetType)) { $this->redirect(self::NOT_FOUND_PAGE_PATH); } if (!empty($id)) { $id = new \MongoId($id); $widget = PageComponent::findByPk($id); if (empty($widget)) { $this->redirect(self::NOT_FOUND_PAGE_PATH); } if (!empty($widget['color'])) { $color = $widget['color']; } $data = $widget['jsonConfig']; } if (empty($data)) { $data = $params['micrositeDefaultConfig'][$widgetType]; } $params = ['type' => $widgetType, 'color' => $color]; $this->view->params = $params; $this->view->params['pageRGBColor'] = join(',', StringUtil::hex2rgb($color)); $this->layout = self::WIDGET_PATH; $this->registerWidgetResource($widgetType); return $this->render(self::WIDGET_PATH . '/' . $widgetType, $data); }