You are here

public function GridStackSkinManager::libraryInfoBuild in GridStack 8.2

Implements hook_library_info_build().

File

src/GridStackSkinManager.php, line 66

Class

GridStackSkinManager
Implements GridStackSkinManagerInterface.

Namespace

Drupal\gridstack

Code

public function libraryInfoBuild() {
  if (!isset($this->libraryInfoBuild)) {
    $libraries = [];
    foreach ($this
      ->getSkins() as $key => $skin) {
      $provider = isset($skin['provider']) ? $skin['provider'] : 'gridstack';
      $id = $provider . '.' . $key;
      foreach ([
        'css',
        'js',
        'dependencies',
      ] as $property) {
        if (isset($skin[$property]) && is_array($skin[$property])) {
          $libraries[$id][$property] = $skin[$property];
        }
      }
      $libraries[$id]['dependencies'][] = 'gridstack/skin';
    }
    foreach (range(1, 12) as $key) {
      $libraries['gridstack.' . $key] = [
        'css' => [
          'layout' => [
            'css/layout/grid-stack-' . $key . '.css' => [],
          ],
        ],
        'dependencies' => [
          'gridstack/library',
        ],
      ];
    }
    $this->libraryInfoBuild = $libraries;
  }
  return $this->libraryInfoBuild;
}