You are here

function animations_library_info_build in Animations (JS/CSS) 8

Implements hook_library_info_build(). For creating dynamic libraries.

File

./animations.module, line 16

Code

function animations_library_info_build() {
  $libs = [];

  // create dynamic libraries from the module config
  $config = \Drupal::config('animations.config');
  foreach ($config
    ->get("animations_dependencies") as $key => $library) {

    // create css library
    if (animations_endsWith($library["file"], "css")) {
      $libs['animations.' . $key] = [
        'css' => [
          'base' => [
            '/libraries/' . $key . '/' . $library["file"] => [],
          ],
        ],
      ];
    }
    else {
      if (animations_endsWith($library["file"], "js")) {
        $libs['animations.' . $key] = [
          'js' => [
            '/libraries/' . $key . '/' . $library["file"] => [],
          ],
        ];
      }
    }
  }
  return $libs;
}