Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Template.php

function Template::getBlockNames

Returns all block names 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

array $context The context:

array $blocks The current set of blocks:

Return value

array<string> An array of block names

File

vendor/twig/twig/src/Template.php, line 259

Class

Template
Default base class for compiled templates.

Namespace

Twig

Code

public function getBlockNames(array $context, array $blocks = []) : array {
    $names = array_merge(array_keys($blocks), array_keys($this->blocks));
    if ($parent = $this->getParent($context)) {
        $names = array_merge($names, $parent->getBlockNames($context));
    }
    return array_unique($names);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal