You are here

protected function GridStackFormBase::getNodes in GridStack 8.2

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

Revert back from keys to keys and values: Original: [[1,0,2,8]. Now: [{"x":1,"y":0,"width":2,"height":8}.

2 calls to GridStackFormBase::getNodes()
GridStackForm::previewForm in modules/gridstack_ui/src/Form/GridStackForm.php
Sets up the preview form.
GridStackFormBase::getNodesNested in modules/gridstack_ui/src/Form/GridStackFormBase.php
Returns JSON for options.breakpoints[xs|sm|md|lg|xl] keyed by nodes.

File

modules/gridstack_ui/src/Form/GridStackFormBase.php, line 630

Class

GridStackFormBase
Extends base form for gridstack instance configuration form.

Namespace

Drupal\gridstack_ui\Form

Code

protected function getNodes($grids = '', $exclude_region = FALSE, $stringify = TRUE) {
  if ($grids) {
    $grids = is_string($grids) ? Json::decode($grids) : $grids;
    $values = [];
    foreach (array_values($grids) as $grid) {
      $value = $this->entity
        ->getNode($grid, $exclude_region);
      $values[] = $value ? (object) $value : [];
    }
    return $stringify ? Json::encode($values) : $values;
  }
  return '';
}