function DynamicPageCacheTestController::cacheableResponse

Same name in other branches
  1. 9 core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/src/DynamicPageCacheTestController.php \Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::cacheableResponse()
  2. 8.9.x core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/src/DynamicPageCacheTestController.php \Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::cacheableResponse()
  3. 11.x core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/src/DynamicPageCacheTestController.php \Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::cacheableResponse()

A route returning a CacheableResponse object.

Return value

\Drupal\Core\Cache\CacheableResponseInterface A CacheableResponseInterface object.

1 string reference to 'DynamicPageCacheTestController::cacheableResponse'
dynamic_page_cache_test.routing.yml in core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.routing.yml
core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.routing.yml

File

core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/src/DynamicPageCacheTestController.php, line 34

Class

DynamicPageCacheTestController
Controller routines for dynamic_page_cache_test routes.

Namespace

Drupal\dynamic_page_cache_test

Code

public function cacheableResponse() {
    $user = User::load(1);
    $response = new CacheableResponse($user->label());
    $response->addCacheableDependency($user);
    return $response;
}

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