function public function LibraryInfo::processLibrary

8.x-3.x LibraryInfo.php public LibraryInfo::processLibrary(array &$libraries, callable $callback)

Processes library definitions.

Parameters

array $libraries: The libraries array, passed by reference.

callable $callback: The callback to perform processing on the library.

Class

LibraryInfo
Implements hook_library_info_alter().

Namespace

Drupal\bootstrap\Plugin\Alter

Source src/Plugin/Alter/LibraryInfo.php (line 83)

public function processLibrary(array &$libraries, callable $callback) {
  foreach ($libraries as &$library) {
    foreach ($library as $type => $definition) {
      if (is_array($definition)) {
        $modified = [];
        // CSS needs special handling since it contains grouping.
        if ($type === 'css') {
          foreach ($definition as $group => $files) {
            foreach ($files as $key => $info) {
              call_user_func_array($callback, [&$info, &$key, $type]);
              $modified[$group][$key] = $info;
            }
          }
        }
        else {
          foreach ($definition as $key => $info) {
            call_user_func_array($callback, [&$info, &$key, $type]);
            $modified[$key] = $info;
          }
        }
        $library[$type] = $modified;
      }
    }
  }
}