W3cubDocs

/Drupal 8

public function CacheableResponseTrait::getCacheableMetadata

public CacheableResponseTrait::getCacheableMetadata()

Returns the cacheability metadata for this response.

Return value

\Drupal\Core\Cache\CacheableMetadata

Overrides CacheableResponseInterface::getCacheableMetadata

File

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

Class

CacheableResponseTrait
Provides an implementation of CacheableResponseInterface.

Namespace

Drupal\Core\Cache

Code

public function getCacheableMetadata() {
  // 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();
  }

  return $this->cacheabilityMetadata;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Cache!CacheableResponseTrait.php/function/CacheableResponseTrait::getCacheableMetadata/8.1.x