eZ\Publish\Core\MVC\Symfony\Templating\Twig\FieldBlockRenderer::searchBlock PHP Method

searchBlock() private method

Returns the block named $blockName in the given template. If it's not found, returns null.
private searchBlock ( string $blockName, Twig_Template $tpl ) : array | null
$blockName string
$tpl Twig_Template
return array | null
    private function searchBlock($blockName, Twig_Template $tpl)
    {
        // Current template might have parents, so we need to loop against
        // them to find a matching block
        do {
            foreach ($tpl->getBlocks() as $name => $block) {
                if ($name === $blockName) {
                    return $block;
                }
            }
        } while (($tpl = $tpl->getParent([])) instanceof Twig_Template);
        return null;
    }