class PageCacheAcceptHeaderController in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/system_test/src/Controller/PageCacheAcceptHeaderController.php \Drupal\system_test\Controller\PageCacheAcceptHeaderController
- 9 core/modules/system/tests/modules/system_test/src/Controller/PageCacheAcceptHeaderController.php \Drupal\system_test\Controller\PageCacheAcceptHeaderController
Defines a controller to respond the page cache accept header test.
Hierarchy
- class \Drupal\system_test\Controller\PageCacheAcceptHeaderController
Expanded class hierarchy of PageCacheAcceptHeaderController
File
- core/
modules/ system/ tests/ modules/ system_test/ src/ Controller/ PageCacheAcceptHeaderController.php, line 12
Namespace
Drupal\system_test\ControllerView source
class PageCacheAcceptHeaderController {
/**
* Processes a request that will vary with Accept header.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request object.
*
* @return mixed
*/
public function content(Request $request) {
if ($request
->getRequestFormat() === 'json') {
return new CacheableJsonResponse([
'content' => 'oh hai this is json',
]);
}
else {
return new CacheableResponse("<p>oh hai this is html.</p>");
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PageCacheAcceptHeaderController:: |
public | function | Processes a request that will vary with Accept header. |