X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fhook%2Flibrary_info_alter.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd8%2Fhook%2Flibrary_info_alter.twig;h=9b08a70d5aa8e8cfacd48066f9198b91e2c2bc08;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/library_info_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/library_info_alter.twig new file mode 100644 index 000000000..9b08a70d5 --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/library_info_alter.twig @@ -0,0 +1,33 @@ +/** + * Implements hook_library_info_alter(). + */ +function {{ machine_name }}_library_info_alter(&$libraries, $extension) { + // Update Farbtastic to version 2.0. + if ($extension == 'core' && isset($libraries['jquery.farbtastic'])) { + // Verify existing version is older than the one we are updating to. + if (version_compare($libraries['jquery.farbtastic']['version'], '2.0', '<')) { + // Update the existing Farbtastic to version 2.0. + $libraries['jquery.farbtastic']['version'] = '2.0'; + // To accurately replace library files, the order of files and the options + // of each file have to be retained; e.g., like this: + $old_path = 'assets/vendor/farbtastic'; + // Since the replaced library files are no longer located in a directory + // relative to the original extension, specify an absolute path (relative + // to DRUPAL_ROOT / base_path()) to the new location. + $new_path = '/' . drupal_get_path('module', 'farbtastic_update') . '/js'; + $new_js = []; + $replacements = [ + $old_path . '/farbtastic.js' => $new_path . '/farbtastic-2.0.js', + ]; + foreach ($libraries['jquery.farbtastic']['js'] as $source => $options) { + if (isset($replacements[$source])) { + $new_js[$replacements[$source]] = $options; + } + else { + $new_js[$source] = $options; + } + } + $libraries['jquery.farbtastic']['js'] = $new_js; + } + } +}