You are here

function rrssb_library_info_alter in Ridiculously Responsive Social Sharing Buttons 8.2

Implements hook_library_info_alter().

File

./rrssb.module, line 106

Code

function rrssb_library_info_alter(&$libraries, $extension) {
  if ($extension == 'rrssb') {
    $libPath = rrssb_library_path();
    $config = \Drupal::config('rrssb.settings');
    if (is_readable("{$libPath}/VERSION.txt")) {
      $libraries['main']['version'] = file_get_contents("{$libPath}/VERSION.txt");
    }
    elseif (is_readable("{$libPath}/package.json")) {
      $packageString = file_get_contents("{$libPath}/package.json");
      $packageJson = json_decode($packageString, TRUE);
      $libraries['main']['version'] = $packageJson['version'];
    }
    if ($config
      ->get('test')) {
      $libraries['main']['js'] = [
        "/{$libPath}/js/rrssb.js" => [],
      ];
    }
    $css = \Drupal::state()
      ->get('rrssb_css_file');
    if ($css) {
      $libraries['init']['css']['component'][$css] = [];
    }
  }
}