You are here

protected function GridStackFormBase::initEngine in GridStack 8.2

Initializes the layout engine.

1 call to GridStackFormBase::initEngine()
GridStackFormBase::form in modules/gridstack_ui/src/Form/GridStackFormBase.php
Gets the actual form array to be built.

File

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

Class

GridStackFormBase
Extends base form for gridstack instance configuration form.

Namespace

Drupal\gridstack_ui\Form

Code

protected function initEngine(array &$form) {
  if ($this->useNested) {
    $engine = $this->framework;
    $form['#attributes']['class'][] = 'form--framework is-framework';
    $form['#attributes']['class'][] = 'form--' . $this->framework;
    $this->settings = $this
      ->getNestedSettings();
  }
  else {

    // Always use default js-driven for the admin preview.
    $engine = 'gridstack_js';
    $form['#attributes']['class'][] = 'form--gridstack-js';
  }
  $this->engine = $this->manager
    ->engineManager()
    ->load($engine);
  $this->engine
    ->setOptionset($this
    ->gridStack());
  $this->iconBreakpoint = $this->engine
    ->getIconBreakpoint();
  $breakpoints = $this
    ->getApplicableBreakpoints();
  $this->breakpointCount = count($breakpoints);
  $this->smallestBreakpoint = $this->engine
    ->getSmallestBreakpoint();
  $form['#attributes']['class'][] = 'form--' . $this->engine
    ->get('group');
  $form['#attributes']['data-gs-breakpoint-count'] = $this->breakpointCount;
  $form['#attributes']['data-gs-smallest'][] = $this->smallestBreakpoint;
  $this
    ->regionForm($form);
}