function Template::hasBlock
Returns whether a block exists or not in the current context of the template.
This method checks blocks defined in the current template or defined in "used" traits or defined in parent templates.
Parameters
string $name The block name:
array $context The context:
array $blocks The current set of blocks:
Return value
bool true if the block exists, false otherwise
File
-
vendor/
twig/ twig/ src/ Template.php, line 231
Class
- Template
- Default base class for compiled templates.
Namespace
TwigCode
public function hasBlock($name, array $context, array $blocks = []) : bool {
if (isset($blocks[$name])) {
return $blocks[$name][0] instanceof self;
}
if (isset($this->blocks[$name])) {
return true;
}
if ($parent = $this->getParent($context)) {
return $parent->hasBlock($name, $context);
}
return false;
}