summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Asset/AttachedAssetsInterface.php
blob: 18dec5904d96fec32520708a9905a37639090434 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php

namespace Drupal\Core\Asset;

/**
 * The attached assets collection for the current response.
 *
 * Allows for storage of:
 * - an ordered list of asset libraries (to be loaded for the current response)
 * - attached JavaScript settings (to be loaded for the current response)
 * - a set of asset libraries that the client already has loaded (as indicated
 *   in the request, to *not* be loaded for the current response)
 *
 * @see \Drupal\Core\Asset\AssetResolverInterface
 */
interface AttachedAssetsInterface {

  /**
   * Creates an AttachedAssetsInterface object from a render array.
   *
   * @param array $render_array
   *   A render array.
   *
   * @return static
   *
   * @throws \LogicException
   */
  public static function createFromRenderArray(array $render_array);

  /**
   * Sets the asset libraries attached to the current response.
   *
   * @param string[] $libraries
   *   A list of libraries, in the order they should be loaded.
   *
   * @return $this
   */
  public function setLibraries(array $libraries);

  /**
   * Returns the asset libraries attached to the current response.
   *
   * @return string[]
   *   A list of libraries attached to this response.
   */
  public function getLibraries();

  /**
   * Sets the JavaScript settings that are attached to the current response.
   *
   * @param array $settings
   *   The needed JavaScript settings.
   *
   * @return $this
   */
  public function setSettings(array $settings);

  /**
   * Returns the settings attached to the current response.
   *
   * @return array
   *   An array of the settings attached to the current response.
   */
  public function getSettings();

  /**
   * Sets the asset libraries that the current request marked as already loaded.
   *
   * @param string[] $libraries
   *   The set of already loaded libraries.
   *
   * @return $this
   */
  public function setAlreadyLoadedLibraries(array $libraries);

  /**
   * Returns the set of already loaded asset libraries.
   *
   * @return string[]
   *   A list of the loaded libraries.
   */
  public function getAlreadyLoadedLibraries();

}