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
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
      • Traits
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

Classes

  • FileLoader
  • StringLoader
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
 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 StringLoader implements Latte\ILoader
17: {
18:     use Latte\Strict;
19: 
20:     /** @var array|null [name => content] */
21:     private $templates;
22: 
23: 
24:     public function __construct(array $templates = null)
25:     {
26:         $this->templates = $templates;
27:     }
28: 
29: 
30:     /**
31:      * Returns template source code.
32:      * @return string
33:      */
34:     public function getContent($name)
35:     {
36:         if ($this->templates === null) {
37:             return $name;
38:         } elseif (isset($this->templates[$name])) {
39:             return $this->templates[$name];
40:         } else {
41:             throw new \RuntimeException("Missing template '$name'.");
42:         }
43:     }
44: 
45: 
46:     /**
47:      * @return bool
48:      */
49:     public function isExpired($name, $time)
50:     {
51:         return false;
52:     }
53: 
54: 
55:     /**
56:      * Returns referred template name.
57:      * @return string
58:      */
59:     public function getReferredName($name, $referringName)
60:     {
61:         if ($this->templates === null) {
62:             throw new \LogicException("Missing template '$name'.");
63:         }
64:         return $name;
65:     }
66: 
67: 
68:     /**
69:      * Returns unique identifier for caching.
70:      * @return string
71:      */
72:     public function getUniqueId($name)
73:     {
74:         return $this->getContent($name);
75:     }
76: }
77: 
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0