示例#1
0
文件: Resource.php 项目: darya/smarty
 /**
  * Fetch the given template using the resource's view resolver.
  * 
  * @param string $name
  * @param string $source
  * @param int    $mtime
  */
 public function fetch($name, &$source, &$mtime)
 {
     if ($path = $this->resolver->resolve($name)) {
         $source = file_get_contents($path);
         $mtime = filemtime($path);
     }
 }
示例#2
0
 /**
  * Handle the given request and response in the case of a routing error.
  * 
  * @param Request  $request
  * @param Response $response
  * @return mixed
  */
 public function handle(Request $request, Response $response)
 {
     $status = $response->status();
     $response->content("{$status} error.");
     if ($this->view->exists("errors/{$status}")) {
         $response->content($this->view->create("errors/{$status}", array('http_host' => $request->host(), 'request_uri' => $request->path(), 'signature' => $request->server('server_signature'))));
     }
     return $response;
 }
示例#3
0
 public function create($path = null, $vars = array())
 {
     $engine = parent::create($path, $vars);
     $engine->smarty()->registerResource('darya', new Resource($this));
     $engine->smarty()->default_resource_type = 'darya';
     return $engine;
 }
示例#4
0
 /**
  * Attempt to resolve the given view path to a file path using the view's
  * resolver or that class's shared resolver.
  * 
  * @param string $path
  * @return string
  */
 protected function resolve($path)
 {
     if ($this->resolver) {
         return $this->resolver->resolve($path);
     } else {
         if (static::$sharedResolver) {
             return static::$sharedResolver->resolve($path);
         }
     }
     return null;
 }