You are here

function fontawesome_library_info_alter in Font Awesome Icons 8

Same name and namespace in other branches
  1. 8.2 fontawesome.module \fontawesome_library_info_alter()

Implements hook_library_info_alter().

File

./fontawesome.module, line 27
Drupal integration with Font Awesome, the iconic font for use with Bootstrap.

Code

function fontawesome_library_info_alter(&$libraries, $extension) {

  // Modify the Font Awesome library to use external file if user chose.
  if ($extension == 'fontawesome' && isset($libraries['fontawesome.cdn'])) {

    // Check if we are using external file.
    $configuration_settings = \Drupal::config('fontawesome.settings')
      ->get();

    // If the user has opted to load an external file, we load it instead.
    if ($configuration_settings['fontawesome_use_cdn'] && !empty($configuration_settings['fontawesome_external_location'])) {
      array_shift($libraries['fontawesome.cdn']['css']['theme']);
      $libraries['fontawesome.cdn']['css']['theme'] = [
        $configuration_settings['fontawesome_external_location'] => [
          'type' => 'external',
          'minified' => 1,
        ],
      ];
    }
  }
}