Пример #1
0
 /**
  * @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
 /**
  * @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
 /**
  * @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() : []);
     }
 }