/** * @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; }
/** * @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; }
/** * @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() : []); } }