示例#1
0
 public function run()
 {
     $model = \hass\area\models\Area::findByIdOrSlug($this->slug);
     $blocks = $model->getBlocks();
     $result = "";
     foreach ($blocks as $block) {
         $widget = $block["widget"];
         $header = Html::tag("h3", $block->title);
         $content = Html::tag("div", $header, ["class" => $this->headerClass]);
         $body = $widget::widget(["model" => $block]);
         $content .= Html::tag("div", $body, ["class" => $this->bodyClass]);
         $result .= Html::tag("div", $content, ["class" => $this->blockClass]);
     }
     return $result;
 }
 /**
  * Finds the Area model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  * @return Area the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Area::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }