function system_region_list in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/system.module \system_region_list()
- 4 modules/system.module \system_region_list()
- 5 modules/system/system.module \system_region_list()
- 6 modules/system/system.module \system_region_list()
- 7 modules/system/system.module \system_region_list()
- 9 core/modules/system/system.module \system_region_list()
Get a list of available regions from a specified theme.
Parameters
\Drupal\Core\Extension\Extension|string $theme: A theme extension object, or the name of a theme.
$show: Possible values: REGIONS_ALL or REGIONS_VISIBLE. Visible excludes hidden regions.
Return value
An array of regions in the form $region['name'] = 'description'.
9 calls to system_region_list()
- Block::preSave in core/modules/ block/ src/ Entity/ Block.php 
- Acts on an entity before the presave hook is invoked.
- BlockController::getVisibleRegionNames in core/modules/ block/ src/ Controller/ BlockController.php 
- Returns the human-readable list of regions keyed by machine name.
- BlockDeleteForm::systemRegionList in core/modules/ block/ src/ Form/ BlockDeleteForm.php 
- Wraps system_region_list().
- BlockForm::form in core/modules/ block/ src/ BlockForm.php 
- Gets the actual form array to be built.
- BlockListBuilder::systemRegionList in core/modules/ block/ src/ BlockListBuilder.php 
- Wraps system_region_list().
File
- core/modules/ system/ system.module, line 883 
- Configuration system that lets administrators modify the workings of the site.
Code
function system_region_list($theme, $show = REGIONS_ALL) {
  if (!$theme instanceof Extension) {
    $themes = \Drupal::service('theme_handler')
      ->listInfo();
    if (!isset($themes[$theme])) {
      return [];
    }
    $theme = $themes[$theme];
  }
  $list = [];
  $info = $theme->info;
  // If requested, suppress hidden regions. See block_admin_display_form().
  foreach ($info['regions'] as $name => $label) {
    if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) {
      $list[$name] = t($label);
    }
  }
  return $list;
}