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
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • FileLoader
  • StringLoader
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Latte (https://latte.nette.org)
 5:  * Copyright (c) 2008 David Grudl (https://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:             if (@touch($file) === FALSE) {
30:                 $tmp = error_get_last();
31:                 trigger_error("File's modification time is in the future. Cannot update it: $tmp[message]", E_USER_WARNING);
32:             }
33:         }
34:         return file_get_contents($file);
35:     }
36: 
37: 
38:     /**
39:      * @return bool
40:      */
41:     public function isExpired($file, $time)
42:     {
43:         return @filemtime($file) > $time; // @ - stat may fail
44:     }
45: 
46: 
47:     /**
48:      * Returns fully qualified template name.
49:      * @return string
50:      */
51:     public function getChildName($file, $parent = NULL)
52:     {
53:         if ($parent && !preg_match('#/|\\\\|[a-z][a-z0-9+.-]*:#iA', $file)) {
54:             $file = dirname($parent) . '/' . $file;
55:         }
56:         return $file;
57:     }
58: 
59: }
60: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0