|
4 | 4 |
|
5 | 5 | use Magento\Framework\ObjectManagerInterface; |
6 | 6 | use Magento\Framework\Event\ManagerInterface; |
| 7 | +use Magento\Framework\View\Element\AbstractBlock; |
7 | 8 | use Magento\Framework\View\TemplateEngine\Php; |
8 | 9 | use Magento\Framework\App\Helper\AbstractHelper; |
9 | 10 | use Magento\Framework\View\Element\BlockInterface; |
@@ -87,6 +88,11 @@ private function initTwig() |
87 | 88 | $this->twig->addFunction(new \Twig\TwigFunction('layoutBlock', [$this, 'layoutBlock'])); |
88 | 89 | $this->twig->addFunction(new \Twig\TwigFunction('get*', [$this, 'catchGet'])); |
89 | 90 | $this->twig->addFunction(new \Twig\TwigFunction('isset', [$this, '__isset'])); |
| 91 | + $this->twig->addFunction(new \Twig\TwigFunction('child_html', [$this, 'getChildHtml'], [ |
| 92 | + 'needs_context' => true, |
| 93 | + 'is_safe' => ['html'] |
| 94 | + ])); |
| 95 | + |
90 | 96 | $this->twig->addFilter(new \Twig\TwigFilter('trans', '__')); |
91 | 97 | $this->twig->addExtension(new \Twig\Extension\DebugExtension()); |
92 | 98 | foreach ($this->getDefinedFunctionsInHelpersFile() as $functionName) { |
@@ -198,6 +204,18 @@ public function helper($className) |
198 | 204 | return $helper; |
199 | 205 | } |
200 | 206 |
|
| 207 | + public function getChildHtml(array $context, $alias = '', $useCache = true) |
| 208 | + { |
| 209 | + if (!isset($context['block'])) { |
| 210 | + return null; |
| 211 | + } |
| 212 | + $block = $context['block']; |
| 213 | + if (!$block instanceof AbstractBlock) { |
| 214 | + return null; |
| 215 | + } |
| 216 | + return $block->getChildHtml($alias, $useCache); |
| 217 | + } |
| 218 | + |
201 | 219 | /** |
202 | 220 | * @return array |
203 | 221 | * @throws \Magento\Framework\Exception\FileSystemException |
|
0 commit comments