public function GridStackEnginePluginBase::buildItems in GridStack 8.2
Builds GridStack boxes to support nested grids for Bootstrap/ Foundation.
The nested grids require extra tools like DS, Panelizer, or Widget, to arrange them into their relevant container, e.g.: DS region, Widget block.
Parameters
array $build: An associative array containing:
- items: An array of gridstack contents: text, image or media.
- options: An array of key:value pairs of custom JS options.
- optionset: The cached optionset object to avoid multiple invocations.
- settings: An array of key:value pairs of HTML/layout related settings.
Return value
array The renderable array of a GridStack instance, or empty array.
Overrides GridStackEnginePluginInterface::buildItems
1 call to GridStackEnginePluginBase::buildItems()
- GridStackEnginePluginBase::build in src/
GridStackEnginePluginBase.php - Alters GridStack build.
File
- src/
GridStackEnginePluginBase.php, line 277
Class
- GridStackEnginePluginBase
- Provides base class for all gridstack layout engines.
Namespace
Drupal\gridstackCode
public function buildItems(array $build) {
$settings = $build['settings'];
$settings = array_diff_key($settings, GridStackDefault::regionSettings());
$grids = $this->optionset
->getLastBreakpoint();
$items = [];
$regions = $this->optionset
->prepareRegions(FALSE);
// Cleans up top level settings.
unset($settings['cache_metadata'], $settings['cache_tags'], $settings['_item']);
foreach ($build['items'] as $delta => $item) {
// Skips if more than we can chew, otherwise broken grid anyway.
if (!isset($grids[$delta])) {
continue;
}
$rid = GridStackDefault::regionId($delta);
$region = isset($regions[$rid]) ? $regions[$rid] : [];
$config = isset($item['settings']) ? array_merge($settings, $item['settings']) : $settings;
$config['region'] = $region;
$config['delta'] = $config['root_delta'] = $delta;
$config['rid'] = $rid;
// @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($delta, $config, $item, $regions);
}
return $items;
}