file CdnJs.php

Namespace

Drupal\bootstrap\Plugin\Provider
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Provider;
  3. /**
  4. * The "cdnjs" CDN Provider plugin.
  5. *
  6. * @ingroup plugins_provider
  7. *
  8. * @BootstrapProvider(
  9. * id = "cdnjs",
  10. * label = @Translation("CDNJS"),
  11. * description = @Translation("CDNJS is one of the most famous free and public web front-end CDN services which is used by ~2,999,000 websites worldwide."),
  12. * )
  13. */
  14. class CdnJs extends ApiProviderBase {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. protected function getApiAssetsUrlTemplate() {
  19. return 'https://api.cdnjs.com/libraries/@library';
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. protected function getApiVersionsUrlTemplate() {
  25. return 'https://api.cdnjs.com/libraries/@library';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. protected function getCdnUrlTemplate() {
  31. return 'https://cdnjs.cloudflare.com/ajax/libs/@library/@version/@file';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. protected function mapLibrary($library) {
  37. // The cdnjs uses the old library name and doesn't have an alias.
  38. if ($library === 'bootstrap') {
  39. return 'twitter-bootstrap';
  40. }
  41. return parent::mapLibrary($library);
  42. }
  43. }

Classes

Name Description
CdnJs The "cdnjs" CDN Provider plugin.