protected function GridStackEnginePluginBase::buildNestedItems in GridStack 8.2
Provides nested items if so configured.
1 call to GridStackEnginePluginBase::buildNestedItems()
- GridStackEnginePluginBase::modifyNestedItem in src/
GridStackEnginePluginBase.php - Modifies nested item contents and attributes.
File
- src/
GridStackEnginePluginBase.php, line 314
Class
- GridStackEnginePluginBase
- Provides base class for all gridstack layout engines.
Namespace
Drupal\gridstackCode
protected function buildNestedItems($delta, array &$settings, array $item, array $grids, array $regions = []) {
$items = [];
$index = $delta + 1;
foreach (array_keys($grids) as $gid) {
$rid = GridStackDefault::regionId($delta . '_' . $gid);
$region = isset($regions[$rid]) ? $regions[$rid] : [];
$nested = isset($item[$gid]) ? $item[$gid] : [];
$config = isset($nested['settings']) ? array_merge($settings, $nested['settings']) : $settings;
$config['region'] = $region;
$config['rid'] = $rid;
$config['nested_delta'] = $gid;
$config['nested_id'] = $region['_context'];
$config['use_inner'] = TRUE;
// @todo move and refactor into region for consistent info back|front-end.
foreach ([
'_level',
'_context',
'_root',
] as $key) {
$config[$key] = isset($region[$key]) ? $region[$key] : FALSE;
}
$items[] = $this
->buildItem($gid, $config, $nested, $regions);
}
// Provides nested gridstack, gridstack within gridstack, if so configured.
$settings['_root'] = 'grids';
$settings['_level'] = GridStackDefault::LEVEL_NESTED;
$settings['_context'] = GridStackDefault::NESTED . $index;
$settings['ungrid'] = !empty($settings['_ungrid']);
// Update box with nested boxes.
return [
'#theme' => 'gridstack',
'#items' => $items,
'#optionset' => $this->optionset,
'#settings' => $settings,
'#attributes' => $this
->nestedContainerAttributes($settings),
];
}