You are here

function ds_extras_ds_layout_region_alter in Display Suite 8.3

Same name and namespace in other branches
  1. 8.2 modules/ds_extras/ds_extras.module \ds_extras_ds_layout_region_alter()
  2. 7.2 modules/ds_extras/ds_extras.module \ds_extras_ds_layout_region_alter()
  3. 7 modules/ds_extras/ds_extras.module \ds_extras_ds_layout_region_alter()

Implements hook_ds_layout_region_alter().

File

modules/ds_extras/ds_extras.module, line 385
Display Suite extras main functions.

Code

function ds_extras_ds_layout_region_alter($context, &$region_info) {
  $region_blocks = \Drupal::config('ds_extras.settings')
    ->get('region_blocks');

  // Bail out if region_blocks is empty or we are working on default view mode.
  if (empty($region_blocks) || $context['view_mode'] == 'default') {
    return;
  }
  $entity_type = $context['entity_type'];
  $bundle = $context['bundle'];
  $view_mode = $context['view_mode'];
  foreach ($region_blocks as $block_key => $block) {
    if ($block['info'] == "{$entity_type}_{$bundle}_{$view_mode}") {
      $region_info['region_options'][$block_key] = $block['title'];
      if (isset($region_info['table_regions'])) {
        $region_info['table_regions'][$block_key] = [
          'title' => Html::escape($block['title']),
          'message' => t('No fields are displayed in this region'),
        ];
      }
    }
  }
}