You are here

private function ContextGroupsBlockPageVariant::getNonEmptyContextGroups in Context groups 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/DisplayVariant/ContextGroupsBlockPageVariant.php \Drupal\context_groups\Plugin\DisplayVariant\ContextGroupsBlockPageVariant::getNonEmptyContextGroups()

Get non empty context groups.

Parameters

array $build: Render array.

Return value

array Returns array of context groups which should be rendered.

1 call to ContextGroupsBlockPageVariant::getNonEmptyContextGroups()
ContextGroupsBlockPageVariant::build in src/Plugin/DisplayVariant/ContextGroupsBlockPageVariant.php

File

src/Plugin/DisplayVariant/ContextGroupsBlockPageVariant.php, line 142

Class

ContextGroupsBlockPageVariant
Provides a page display variant that decorates the main content with blocks.

Namespace

Drupal\context_groups\Plugin\DisplayVariant

Code

private function getNonEmptyContextGroups(array $build) {
  $not_empty_context_groups = [];
  foreach (Element::children($build) as $region_name) {
    foreach ($build[$region_name] as $block) {
      if (!empty($block['#configuration']['all_parents'])) {
        $not_empty_context_groups = array_unique(array_merge($block['#configuration']['all_parents'], $not_empty_context_groups));
      }
    }
  }
  return $not_empty_context_groups;
}