1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Latte\Macros;
9:
10: use Latte;
11: use Latte\RuntimeException;
12:
13:
14: 15: 16:
17: class BlockMacrosRuntime extends Latte\Object
18: {
19:
20: 21: 22: 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: 37: 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: