public function GridStackManager::build in GridStack 8.2
Same name and namespace in other branches
- 8 src/GridStackManager.php \Drupal\gridstack\GridStackManager::build()
Returns a cacheable renderable array of a single gridstack instance.
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 cacheable renderable array of a gridstack instance, or empty array.
Overrides GridStackManagerInterface::build
File
- src/
GridStackManager.php, line 282
Class
- GridStackManager
- Implements GridStackManagerInterface.
Namespace
Drupal\gridstackCode
public function build(array $build = []) {
foreach ([
'attached',
'layout',
'variant',
] + GridStackDefault::themeProperties() as $key) {
$build[$key] = isset($build[$key]) ? $build[$key] : [];
}
$gridstack = [
'#theme' => 'gridstack',
'#build' => $build,
'#pre_render' => [
[
$this,
'preRenderGridStack',
],
],
'items' => [],
'#layout' => $build['layout'],
];
$this->moduleHandler
->alter('gridstack_build', $gridstack, $build['settings']);
return empty($build['items']) ? [] : $gridstack;
}