You are here

public function GridStack::getJsonSummaryNestedBreakpoints in GridStack 8.2

Returns JSON for options.breakpoints[xs|sm|md|lg|xl] keyed by indices.

Simplify and remove keys: Original: [{"x":1,"y":0,"width":2,"height":8}. Now: [[1,0,2,8].

File

src/Entity/GridStack.php, line 300

Class

GridStack
Defines the GridStack configuration entity.

Namespace

Drupal\gridstack\Entity

Code

public function getJsonSummaryNestedBreakpoints($breakpoint = 'lg', $nested = '', $grids = '') {
  if ($nested) {
    $grids = $grids ?: $this
      ->getBreakpointItems($breakpoint, 'grids', FALSE);
    $grids = is_string($grids) ? Json::decode($grids) : $grids;
    $nested = is_string($nested) ? Json::decode($nested) : $nested;
    $values = [];
    foreach (array_keys($grids) as $id) {
      if (isset($nested[$id])) {
        if (empty($nested[$id])) {
          $values[] = [];
        }
        else {
          foreach ($nested[$id] as $grid) {
            $values[$id][] = array_values($grid);
          }
        }
      }
    }
    return Json::encode($values);
  }
  return '';
}