Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • FileLoader
  • StringLoader
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Latte (http://latte.nette.org)
 5:  * Copyright (c) 2008 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Latte\Loaders;
 9: 
10: use Latte;
11: 
12: 
13: /**
14:  * Template loader.
15:  */
16: class FileLoader extends Latte\Object implements Latte\ILoader
17: {
18: 
19:     /**
20:      * Returns template source code.
21:      * @return string
22:      */
23:     public function getContent($file)
24:     {
25:         if (!is_file($file)) {
26:             throw new \RuntimeException("Missing template file '$file'.");
27: 
28:         } elseif ($this->isExpired($file, time())) {
29:             touch($file);
30:         }
31:         return file_get_contents($file);
32:     }
33: 
34: 
35:     /**
36:      * @return bool
37:      */
38:     public function isExpired($file, $time)
39:     {
40:         return @filemtime($file) > $time; // @ - stat may fail
41:     }
42: 
43: 
44:     /**
45:      * Returns fully qualified template name.
46:      * @return string
47:      */
48:     public function getChildName($file, $parent = NULL)
49:     {
50:         if ($parent && !preg_match('#/|\\\\|[a-z][a-z0-9+.-]*:#iA', $file)) {
51:             $file = dirname($parent) . '/' . $file;
52:         }
53:         return $file;
54:     }
55: 
56: }
57: 
Nette 2.3.4 API API documentation generated by ApiGen 2.8.0