You are here

public function GridStack::getJsonSummaryBreakpoints in GridStack 8

Same name and namespace in other branches
  1. 8.2 src/Entity/GridStack.php \Drupal\gridstack\Entity\GridStack::getJsonSummaryBreakpoints()

Returns JSON for options.breakpoints.

File

src/Entity/GridStack.php, line 320

Class

GridStack
Defines the GridStack configuration entity.

Namespace

Drupal\gridstack\Entity

Code

public function getJsonSummaryBreakpoints($breakpoint = 'lg', $exclude_image_style = FALSE, $no_keys = TRUE) {
  $grids = $this
    ->getBreakpointGrids($breakpoint);
  if ($grids && $no_keys) {
    $values = [];
    foreach ($grids as &$grid) {
      if (empty($grid)) {
        continue;
      }
      if ($exclude_image_style && isset($grid['image_style'])) {
        array_pop($grid);
      }
      $values[] = array_values($grid);
    }

    // Simplify and remove keys:
    // Original: [{"x":1,"y":0,"width":2,"height":8}.
    // Now: [[1,0,2,8].
    $grids = $values;
  }
  return $grids ? Json::encode($grids) : '';
}