You are here

protected static function LibraryBuilderTest::minify in The CodeMirror Editor 8

Minifies file names in library definition.

Parameters

array $library_definition: The library definition.

Return value

array Processed library definition.

1 call to LibraryBuilderTest::minify()
LibraryBuilderTest::testLibraryBuild in tests/src/Kernel/LibraryBuilderTest.php
Test callback.

File

tests/src/Kernel/LibraryBuilderTest.php, line 191

Class

LibraryBuilderTest
A test for codemirror_editor_library_info_build().

Namespace

Drupal\Tests\codemirror_editor\Kernel

Code

protected static function minify(array $library_definition) {
  foreach ($library_definition['js'] as $file_name => $options) {
    unset($library_definition['js'][$file_name]);
    $file_name = preg_replace('#\\.js$#', '.min.js', $file_name);
    $options['minified'] = TRUE;
    $library_definition['js'][$file_name] = $options;
  }
  foreach ($library_definition['css']['component'] as $file_name => $options) {
    unset($library_definition['css']['component'][$file_name]);
    $file_name = preg_replace('#\\.css#', '.min.css', $file_name);
    $options['minified'] = TRUE;
    $library_definition['css']['component'][$file_name] = $options;
  }
  return $library_definition;
}