You are here

public function LibraryInfo::processLibrary in Express 8

Processes library definitions.

Parameters

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

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

1 call to LibraryInfo::processLibrary()
LibraryInfo::alter in themes/contrib/bootstrap/src/Plugin/Alter/LibraryInfo.php
Alters data for a specific hook_TYPE_alter() implementation.

File

themes/contrib/bootstrap/src/Plugin/Alter/LibraryInfo.php, line 99
Contains \Drupal\bootstrap\Plugin\Alter\LibraryInfo.

Class

LibraryInfo
Implements hook_library_info_alter().

Namespace

Drupal\bootstrap\Plugin\Alter

Code

public function processLibrary(&$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;
      }
    }
  }
}