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

Breadcrumb

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

function CacheableResponseTrait::addCacheableDependency

1 call to CacheableResponseTrait::addCacheableDependency()
HtmlResponse::setContent in core/lib/Drupal/Core/Render/HtmlResponse.php
Sets the response content.

File

core/lib/Drupal/Core/Cache/CacheableResponseTrait.php, line 22

Class

CacheableResponseTrait
Provides an implementation of CacheableResponseInterface.

Namespace

Drupal\Core\Cache

Code

public function addCacheableDependency($dependency) {
    // A trait doesn't have a constructor, so initialize the cacheability
    // metadata if that hasn't happened yet.
    if (!isset($this->cacheabilityMetadata)) {
        $this->cacheabilityMetadata = new CacheableMetadata();
    }
    $this->cacheabilityMetadata = $this->cacheabilityMetadata
        ->merge(CacheableMetadata::createFromObject($dependency));
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal