public static function GridStack::optimizeGridWidths in GridStack 8
Optimize grid widths to remove similar widths.
This is premature optimization, postpone.
@todo: Optimize more to be executed once. @todo: Correct logic to only remove one level down with similarity.
File
- src/
Entity/ GridStack.php, line 290
Class
- GridStack
- Defines the GridStack configuration entity.
Namespace
Drupal\gridstack\EntityCode
public static function optimizeGridWidths(array $settings = [], $current = 'grids', $optimize = FALSE) {
$breakpoints = isset($settings['breakpoints']) ? $settings['breakpoints'] : [];
$delta = isset($settings['delta']) ? $settings['delta'] : 0;
$nested_delta = isset($settings['nested_delta']) ? $settings['nested_delta'] : NULL;
$unique = [];
foreach (self::getConstantBreakpoints() as $id) {
$item = isset($breakpoints[$id]) && isset($breakpoints[$id][$current][$delta]) ? $breakpoints[$id][$current][$delta] : '';
if (empty($item)) {
continue;
}
if ($current == 'grids') {
if (!empty($item['width'])) {
$unique[$id] = (int) $item['width'];
}
}
elseif ($current == 'nested') {
if (isset($item[$nested_delta]) && !empty($item[$nested_delta]['width'])) {
$unique[$id] = (int) $item[$nested_delta]['width'];
}
}
}
return $optimize ? array_unique($unique) : $unique;
}