1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace think\response;
- use think\Config;
- use think\Response;
- use think\View as ViewTemplate;
- class View extends Response
- {
-
- protected $options = [];
- protected $vars = [];
- protected $replace = [];
- protected $contentType = 'text/html';
-
- protected function output($data)
- {
-
- return ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str'))
- ->fetch($data, $this->vars, $this->replace);
- }
-
- public function getVars($name = null)
- {
- if (is_null($name)) {
- return $this->vars;
- } else {
- return isset($this->vars[$name]) ? $this->vars[$name] : null;
- }
- }
-
- public function assign($name, $value = '')
- {
- if (is_array($name)) {
- $this->vars = array_merge($this->vars, $name);
- return $this;
- } else {
- $this->vars[$name] = $value;
- }
- return $this;
- }
-
- public function replace($content, $replace = '')
- {
- if (is_array($content)) {
- $this->replace = array_merge($this->replace, $content);
- } else {
- $this->replace[$content] = $replace;
- }
- return $this;
- }
- }
|