LibraryDiscoveryInterface.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Drupal\Core\Asset;
  3. /**
  4. * Discovers information for asset (CSS/JavaScript) libraries.
  5. *
  6. * Library information is statically cached. Libraries are keyed by extension
  7. * for several reasons:
  8. * - Libraries are not unique. Multiple extensions might ship with the same
  9. * library in a different version or variant. This registry cannot (and does
  10. * not attempt to) prevent library conflicts.
  11. * - Extensions implementing and thereby depending on a library that is
  12. * registered by another extension can only rely on that extension's library.
  13. * - Two (or more) extensions can still register the same library and use it
  14. * without conflicts in case the libraries are loaded on certain pages only.
  15. */
  16. interface LibraryDiscoveryInterface {
  17. /**
  18. * Gets all libraries defined by an extension.
  19. *
  20. * @param string $extension
  21. * The name of the extension that registered a library.
  22. *
  23. * @return array
  24. * An associative array of libraries registered by $extension is returned
  25. * (which may be empty).
  26. *
  27. * @see self::getLibraryByName()
  28. */
  29. public function getLibrariesByExtension($extension);
  30. /**
  31. * Gets a single library defined by an extension by name.
  32. *
  33. * @param string $extension
  34. * The name of the extension that registered a library.
  35. * @param string $name
  36. * The name of a registered library to retrieve.
  37. *
  38. * @return array|false
  39. * The definition of the requested library, if $name was passed and it
  40. * exists, otherwise FALSE.
  41. */
  42. public function getLibraryByName($extension, $name);
  43. /**
  44. * Clears static and persistent library definition caches.
  45. */
  46. public function clearCachedDefinitions();
  47. }