TestCacheableDependency.php

Same filename and directory in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/TestCacheableDependency.php
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/TestCacheableDependency.php
  3. 10 core/tests/Drupal/Tests/Core/Render/TestCacheableDependency.php

Namespace

Drupal\Tests\Core\Render

File

core/tests/Drupal/Tests/Core/Render/TestCacheableDependency.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\Core\Render;

use Drupal\Core\Cache\CacheableDependencyInterface;

/**
 * Cacheable dependency object for use in tests.
 */
class TestCacheableDependency implements CacheableDependencyInterface {
  
  /**
   * The cache contexts.
   */
  protected array $contexts;
  
  /**
   * The cache tags.
   */
  protected array $tags;
  
  /**
   * The cache maximum age.
   */
  protected int $maxAge;
  public function __construct(array $contexts, array $tags, $max_age) {
    $this->contexts = $contexts;
    $this->tags = $tags;
    $this->maxAge = $max_age;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return $this->contexts;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    return $this->tags;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return $this->maxAge;
  }

}

Classes

Title Deprecated Summary
TestCacheableDependency Cacheable dependency object for use in tests.

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