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

  • BlockMacros
  • BlockMacrosRuntime
  • CoreMacros
  • MacroSet
  • 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\Macros;
 9: 
10: use Latte;
11: use Latte\RuntimeException;
12: 
13: 
14: /**
15:  * Runtime helpers for block macros.
16:  */
17: class BlockMacrosRuntime extends Latte\Object
18: {
19: 
20:     /**
21:      * Calls block.
22:      * @return void
23:      */
24:     public static function callBlock(\stdClass $context, $name, array $params)
25:     {
26:         if (empty($context->blocks[$name])) {
27:             $hint = isset($context->blocks) && ($t = Latte\Helpers::getSuggestion(array_keys($context->blocks), $name)) ? ", did you mean '$t'?" : '.';
28:             throw new RuntimeException("Cannot include undefined block '$name'$hint");
29:         }
30:         $block = reset($context->blocks[$name]);
31:         $block($context, $params);
32:     }
33: 
34: 
35:     /**
36:      * Calls parent block.
37:      * @return void
38:      */
39:     public static function callBlockParent(\stdClass $context, $name, array $params)
40:     {
41:         if (empty($context->blocks[$name]) || ($block = next($context->blocks[$name])) === FALSE) {
42:             throw new RuntimeException("Cannot include undefined parent block '$name'.");
43:         }
44:         $block($context, $params);
45:         prev($context->blocks[$name]);
46:     }
47: 
48: }
49: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0