コード例 #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
ファイル: ViewResolver.php プロジェクト: darya/smarty
 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
ファイル: AbstractView.php プロジェクト: darya/framework
 /**
  * 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;
 }