Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BubbleableMetadata.php

function BubbleableMetadata::createFromObject

Creates a bubbleable metadata object from a depended object.

Parameters

\Drupal\Core\Cache\CacheableDependencyInterface|mixed $object: The object whose cacheability metadata to retrieve. If it implements CacheableDependencyInterface, its cacheability metadata will be used, otherwise, the passed in object must be assumed to be uncacheable, so max-age 0 is set.

Return value

static

Overrides CacheableMetadata::createFromObject

File

core/lib/Drupal/Core/Render/BubbleableMetadata.php, line 82

Class

BubbleableMetadata
Value object used for bubbleable rendering metadata.

Namespace

Drupal\Core\Render

Code

public static function createFromObject($object) {
    $meta = parent::createFromObject($object);
    if ($object instanceof AttachmentsInterface) {
        $meta->attachments = $object->getAttachments();
    }
    return $meta;
}
RSS feed
Powered by Drupal