You are here

protected function GridStackPluginManagerBase::getData in GridStack 8.2

Returns gridstack plugin data.

1 call to GridStackPluginManagerBase::getData()
GridStackSkinManager::getSkins in src/GridStackSkinManager.php
Returns gridstack skins registered via GridStackSkin plugin or defaults.

File

src/GridStackPluginManagerBase.php, line 162

Class

GridStackPluginManagerBase
Implements GridStackPluginManagerInterface.

Namespace

Drupal\gridstack

Code

protected function getData(array $methods, $flatten = FALSE, array $configuration = []) {
  $cid = static::$key . 's_data';
  if ($cache = $this->cacheBackend
    ->get($cid)) {
    return $cache->data;
  }
  else {
    $data = $items = [];
    foreach ($this
      ->loadMultiple($configuration) as $plugin) {
      if ($flatten) {
        foreach ($methods as $method) {
          $data = NestedArray::mergeDeep($data, $plugin
            ->{$method}());
        }
      }
      else {
        foreach ($methods as $method) {
          $items[$method] = $plugin
            ->{$method}();
        }
        $data = NestedArray::mergeDeep($data, $items);
      }
    }
    ksort($data);
    $count = count($data);
    $tags = Cache::buildTags($cid, [
      'count:' . $count,
    ]);
    $this->cacheBackend
      ->set($cid, $data, Cache::PERMANENT, $tags);
    return $data;
  }
}