Example #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     /**
      * @var $activeWidgets \common\models\Widget
      */
     $activeWidgets = Widget::find()->where(['widget_location' => $this->location])->orderBy(['widget_order' => SORT_ASC])->all();
     if ($activeWidgets) {
         foreach ($activeWidgets as $activeWidget) {
             $this->_widget[] = ArrayHelper::merge($this->defaultConfig, $this->config, $activeWidget->getConfig(), ['id' => $activeWidget->id]);
         }
     }
 }
 /**
  * Finds the Widget model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  *
  * @return Widget the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Widget::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }