interface AttachedAssetsInterface

Same name in other branches
  1. 9 core/lib/Drupal/Core/Asset/AttachedAssetsInterface.php \Drupal\Core\Asset\AttachedAssetsInterface
  2. 8.9.x core/lib/Drupal/Core/Asset/AttachedAssetsInterface.php \Drupal\Core\Asset\AttachedAssetsInterface
  3. 10 core/lib/Drupal/Core/Asset/AttachedAssetsInterface.php \Drupal\Core\Asset\AttachedAssetsInterface

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)

Hierarchy

Expanded class hierarchy of AttachedAssetsInterface

All classes that implement AttachedAssetsInterface

See also

\Drupal\Core\Asset\AssetResolverInterface

12 files declare their use of AttachedAssetsInterface
AssetControllerBase.php in core/modules/system/src/Controller/AssetControllerBase.php
AssetResolverTest.php in core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php
BigPipe.php in core/modules/big_pipe/src/Render/BigPipe.php
ckeditor5.module in core/modules/ckeditor5/ckeditor5.module
common_test.module in core/modules/system/tests/modules/common_test/common_test.module

... See full list

File

core/lib/Drupal/Core/Asset/AttachedAssetsInterface.php, line 16

Namespace

Drupal\Core\Asset
View source
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[]
     */
    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
     */
    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[]
     */
    public function getAlreadyLoadedLibraries();

}

Members

Title Sort descending Modifiers Object type Summary Overrides
AttachedAssetsInterface::createFromRenderArray public static function Creates an AttachedAssetsInterface object from a render array. 1
AttachedAssetsInterface::getAlreadyLoadedLibraries public function Returns the set of already loaded asset libraries. 1
AttachedAssetsInterface::getLibraries public function Returns the asset libraries attached to the current response. 1
AttachedAssetsInterface::getSettings public function Returns the settings attached to the current response. 1
AttachedAssetsInterface::setAlreadyLoadedLibraries public function Sets the asset libraries that the current request marked as already loaded. 1
AttachedAssetsInterface::setLibraries public function Sets the asset libraries attached to the current response. 1
AttachedAssetsInterface::setSettings public function Sets the JavaScript settings that are attached to the current response. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.