public function GridStack::getNode in GridStack 8.2
Returns a node as required by admin storage, or frontend attributes.
File
- src/
Entity/ GridStack.php, line 327
Class
- GridStack
- Defines the GridStack configuration entity.
Namespace
Drupal\gridstack\EntityCode
public function getNode(array $grid, $exclude_region = TRUE) {
$value = [];
// Outlayer ridiculously allows a single WIDTHxHEIGHT to apply for N-grid.
$grid = array_values($grid);
if (isset($grid[3])) {
foreach ([
'x',
'y',
'width',
'height',
] as $key => $node) {
$value[$node] = $grid[$key];
}
$rid = isset($grid[4]) ? 4 : -1;
}
else {
// Outlayer ungridstack (Custom Grid) doesn't provide x, y.
$value = [
'width' => $grid[0],
'height' => $grid[1],
];
$rid = isset($grid[2]) ? 2 : -1;
}
// Post gridstack_update_8211.
if (!$exclude_region && !empty($grid[$rid])) {
$value['region'] = $grid[$rid];
}
return $value;
}