コード例 #1
0
ファイル: SimplePhpView.php プロジェクト: justthefish/hesper
 /**
  * @return SimplePhpView
  **/
 public function render(Model $model = null)
 {
     Assert::isTrue($model === null || $model instanceof Model);
     if ($model) {
         extract($model->getList());
     }
     $partViewer = new PartViewer($this->partViewResolver, $model);
     $this->preRender();
     include $this->templatePath;
     $this->postRender();
     return $this;
 }
コード例 #2
0
ファイル: Model.php プロジェクト: justthefish/hesper
 /**
  * @return Model
  **/
 public function merge(Model $model, $overwrite = false)
 {
     if (!$model->isEmpty()) {
         $vars = $model->getList();
         foreach ($vars as $name => $value) {
             if (!$overwrite && $this->has($name)) {
                 continue;
             }
             $this->set($name, $value);
         }
     }
     return $this;
 }
コード例 #3
0
ファイル: JsonView.php プロジェクト: justthefish/hesper
 /**
  * @param Model $model
  *
  * @return string
  */
 public function toString(Model $model = null)
 {
     Assert::isTrue($model === null || $model instanceof Model);
     if ($this->options) {
         return json_encode($model ? $model->getList() : [], $this->options);
     } else {
         return json_encode($model ? $model->getList() : []);
     }
 }