You are here

public function GridStack::getData in GridStack 8.2

Returns GridStack data as string for container attributes.

File

src/Entity/GridStack.php, line 239

Class

GridStack
Defines the GridStack configuration entity.

Namespace

Drupal\gridstack\Entity

Code

public function getData() {
  if (!isset($this->data)) {
    $data = [];
    if ($breakpoints = $this
      ->breakpointsToArray()) {
      foreach ($breakpoints as $breakpoint) {
        if (isset($breakpoint['width'], $breakpoint['grids'])) {
          $data[$breakpoint['width']] = $this
            ->massageGrids($breakpoint['grids']);
        }
      }
    }
    $this->data = $data ? Json::encode($data) : '';
  }
  return $this->data;
}