You are here

GridStackEngineManager.php in GridStack 8.2

Namespace

Drupal\gridstack

File

src/GridStackEngineManager.php
View source
<?php

namespace Drupal\gridstack;


/**
 * Implements GridStackEngineManagerInterface.
 */
class GridStackEngineManager extends GridStackPluginManagerBase implements GridStackEngineManagerInterface {

  /**
   * {@inheritdoc}
   */
  protected static $path = 'Plugin/gridstack/engine';

  /**
   * {@inheritdoc}
   */
  protected static $interface = 'Drupal\\gridstack\\GridStackEnginePluginInterface';

  /**
   * {@inheritdoc}
   */
  protected static $annotation = 'Drupal\\gridstack\\Annotation\\GridStackEngine';

  /**
   * {@inheritdoc}
   */
  protected static $key = 'gridstack_engine';

  /**
   * The active CSS framework.
   *
   * @var array
   */
  protected $framework;

  /**
   * The gridstack layout CSS classes applicable to .row or .box__content.
   *
   * @var array
   */
  protected $classOptions;

  /**
   * Provides gridstack skins and libraries.
   */
  public function attach(array &$load, array $attach = []) {
    if (isset($attach['_engine']) && ($engine = $attach['_engine'])) {
      $this
        ->load($engine, $attach)
        ->attach($load, $attach);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function framework(array $configuration = []) {
    if (!isset($this->framework)) {
      if ($framework = $this
        ->config('framework')) {
        $this->framework = $this
          ->load($framework, $configuration);
      }
    }
    return $this->framework;
  }

  /**
   * Returns preset classes with the custom defined for .row or .box__content.
   */
  public function getClassOptions($type = 'generic') {
    if (!isset($this->classOptions[$type])) {
      if ($this
        ->framework()) {
        $this->classOptions[$type] = $type == 'row' ? $this
          ->framework()
          ->rowClassOptions() : $this
          ->framework()
          ->classOptions();
      }
    }
    return $this->classOptions[$type];
  }

}

Classes

Namesort descending Description
GridStackEngineManager Implements GridStackEngineManagerInterface.