You are here

function search_autocomplete_library_info_build in Search Autocomplete 8

Same name and namespace in other branches
  1. 2.x search_autocomplete.module \search_autocomplete_library_info_build()

Implements hook_library_info_build().

Add dynamic library definitions.

Since we can't add files through css in #attached anymore, this is a trick defining as many libraries as the number of found CSS in the theme folder.

Return value

array An array of library definitions.

File

./search_autocomplete.module, line 182
Provides autocompletion in any field from GUI.

Code

function search_autocomplete_library_info_build() {
  $libraries = [];

  // Find all available themes.
  $themes = [];
  $files = file_scan_directory(drupal_get_path('module', 'search_autocomplete') . '/css/themes', '/.*\\.css\\z/', [
    'recurse' => FALSE,
  ]);

  // Create a new library for all themes.
  foreach ($files as $file) {
    $libraries["theme.{$file->filename}"] = [
      'css' => [
        'base' => [
          "css/themes/{$file->filename}" => [],
        ],
      ],
    ];
  }
  return $libraries;
}