UncacheableDependencyTrait.php

Same filename in other branches
  1. 9 core/lib/Drupal/Core/Cache/UncacheableDependencyTrait.php
  2. 8.9.x core/lib/Drupal/Core/Cache/UncacheableDependencyTrait.php
  3. 11.x core/lib/Drupal/Core/Cache/UncacheableDependencyTrait.php

Namespace

Drupal\Core\Cache

File

core/lib/Drupal/Core/Cache/UncacheableDependencyTrait.php

View source
<?php

namespace Drupal\Core\Cache;


/**
 * Trait to implement CacheableDependencyInterface for uncacheable objects.
 *
 * Use this for objects that are never cacheable.
 *
 * @see \Drupal\Core\Cache\CacheableDependencyInterface
 */
trait UncacheableDependencyTrait {
    
    /**
     * {@inheritdoc}
     */
    public function getCacheContexts() {
        return [];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheTags() {
        return [];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheMaxAge() {
        return 0;
    }

}

Traits

Title Deprecated Summary
UncacheableDependencyTrait Trait to implement CacheableDependencyInterface for uncacheable objects.

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