AttachedAssetsInterface.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Drupal\Core\Asset;
  3. /**
  4. * The attached assets collection for the current response.
  5. *
  6. * Allows for storage of:
  7. * - an ordered list of asset libraries (to be loaded for the current response)
  8. * - attached JavaScript settings (to be loaded for the current response)
  9. * - a set of asset libraries that the client already has loaded (as indicated
  10. * in the request, to *not* be loaded for the current response)
  11. *
  12. * @see \Drupal\Core\Asset\AssetResolverInterface
  13. */
  14. interface AttachedAssetsInterface {
  15. /**
  16. * Creates an AttachedAssetsInterface object from a render array.
  17. *
  18. * @param array $render_array
  19. * A render array.
  20. *
  21. * @return \Drupal\Core\Asset\AttachedAssetsInterface
  22. *
  23. * @throws \LogicException
  24. */
  25. public static function createFromRenderArray(array $render_array);
  26. /**
  27. * Sets the asset libraries attached to the current response.
  28. *
  29. * @param string[] $libraries
  30. * A list of libraries, in the order they should be loaded.
  31. *
  32. * @return $this
  33. */
  34. public function setLibraries(array $libraries);
  35. /**
  36. * Returns the asset libraries attached to the current response.
  37. *
  38. * @return string[]
  39. */
  40. public function getLibraries();
  41. /**
  42. * Sets the JavaScript settings that are attached to the current response.
  43. *
  44. * @param array $settings
  45. * The needed JavaScript settings.
  46. *
  47. * @return $this
  48. */
  49. public function setSettings(array $settings);
  50. /**
  51. * Returns the settings attached to the current response.
  52. *
  53. * @return array
  54. */
  55. public function getSettings();
  56. /**
  57. * Sets the asset libraries that the current request marked as already loaded.
  58. *
  59. * @param string[] $libraries
  60. * The set of already loaded libraries.
  61. *
  62. * @return $this
  63. */
  64. public function setAlreadyLoadedLibraries(array $libraries);
  65. /**
  66. * Returns the set of already loaded asset libraries.
  67. *
  68. * @return string[]
  69. */
  70. public function getAlreadyLoadedLibraries();
  71. }