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

  • Loader
  • SnippetBridge
  • Template
  • TemplateFactory
  • UIMacros
  • UIRuntime

Interfaces

  • ILatteFactory
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Bridges\ApplicationLatte;
 9: 
10: use Latte\Runtime\ISnippetBridge;
11: use Nette;
12: use Nette\Application\UI\Control;
13: use Nette\Application\UI\IRenderable;
14: 
15: 
16: /**
17:  * @internal
18:  */
19: class SnippetBridge implements ISnippetBridge
20: {
21:     use Nette\SmartObject;
22: 
23:     /** @var Control */
24:     private $control;
25: 
26:     /** @var \stdClass|null */
27:     private $payload;
28: 
29: 
30:     public function __construct(Control $control)
31:     {
32:         $this->control = $control;
33:     }
34: 
35: 
36:     public function isSnippetMode()
37:     {
38:         return $this->control->snippetMode;
39:     }
40: 
41: 
42:     public function setSnippetMode($snippetMode)
43:     {
44:         $this->control->snippetMode = $snippetMode;
45:     }
46: 
47: 
48:     public function needsRedraw($name)
49:     {
50:         return $this->control->isControlInvalid($name);
51:     }
52: 
53: 
54:     public function markRedrawn($name)
55:     {
56:         if ($name !== '') {
57:             $this->control->redrawControl($name, false);
58:         }
59:     }
60: 
61: 
62:     public function getHtmlId($name)
63:     {
64:         return $this->control->getSnippetId($name);
65:     }
66: 
67: 
68:     public function addSnippet($name, $content)
69:     {
70:         if ($this->payload === null) {
71:             $this->payload = $this->control->getPresenter()->getPayload();
72:         }
73:         $this->payload->snippets[$this->control->getSnippetId($name)] = $content;
74:     }
75: 
76: 
77:     public function renderChildren()
78:     {
79:         $queue = [$this->control];
80:         do {
81:             foreach (array_shift($queue)->getComponents() as $child) {
82:                 if ($child instanceof IRenderable) {
83:                     if ($child->isControlInvalid()) {
84:                         $child->snippetMode = true;
85:                         $child->render();
86:                         $child->snippetMode = false;
87:                     }
88:                 } elseif ($child instanceof Nette\ComponentModel\IContainer) {
89:                     $queue[] = $child;
90:                 }
91:             }
92:         } while ($queue);
93:     }
94: }
95: 
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0