public static function GridStackLayoutTrait::prepareRegions in GridStack 8
Returns regions based on available grids.
Parameters
mixed $optionset: The \Drupal\gridstack\Entity\GridStack optionset instance.
bool $clean: The flag to exclude region containers.
Return value
array Available regions by the given $optionset parameter, else empty.
4 calls to GridStackLayoutTrait::prepareRegions()
- GridStackLayout::buildConfigurationForm in src/
Layout/ GridStackLayout.php - Form constructor.
- GridStackLayout::layoutAlter in src/
Layout/ GridStackLayout.php - Implements hook_layout_alter().
- GridStackLayoutDeprecated::buildConfigurationForm in src/
Layout/ GridStackLayoutDeprecated.php - Form constructor.
- GridStackLayoutDeprecated::layoutAlter in src/
Layout/ GridStackLayoutDeprecated.php - Implements hook_layout_alter().
File
- src/
Layout/ GridStackLayoutTrait.php, line 40
Class
- GridStackLayoutTrait
- A Trait common for optional layout integration.
Namespace
Drupal\gridstack\LayoutCode
public static function prepareRegions($optionset = NULL, $clean = TRUE) {
$grids = $optionset
->getEndBreakpointGrids();
$regions = [];
foreach ($grids as $delta => $grid) {
$label_index = $delta + 1;
$label = 'GridStack ' . $label_index;
$regions['gridstack_' . $delta]['label'] = new TranslatableMarkup('@label', [
'@label' => $label,
]);
// With nested grids, its container doesn't contain contents, but grids.
$nested_grids = $optionset
->getNestedGridsByDelta($delta);
$is_nested = array_filter($nested_grids);
if (!empty($is_nested)) {
// Remove container since the actual contents are moved, if required.
if ($clean) {
unset($regions['gridstack_' . $delta]);
}
foreach ($nested_grids as $nested_delta => $nested_grid) {
$label_index_nested = $nested_delta + 1;
$label = 'GridStack ' . $label_index . ':' . $label_index_nested;
$regions['gridstack_' . $delta . '_' . $nested_delta]['label'] = new TranslatableMarkup('@label', [
'@label' => $label,
]);
}
}
}
return $regions;
}