function ResourceResponseSubscriberTest::generateRouteRequirements
Generates route requirements based on supported formats.
Parameters
array $supported_response_formats: The supported response formats to add to the route requirements.
array $supported_request_formats: The supported request formats to add to the route requirements.
Return value
array An array of route requirements.
3 calls to ResourceResponseSubscriberTest::generateRouteRequirements()
- ResourceResponseSubscriberTest::testOnResponseWithCacheableResponse in core/
modules/ rest/ tests/ src/ Unit/ EventSubscriber/ ResourceResponseSubscriberTest.php - Tests on response with cacheable response.
- ResourceResponseSubscriberTest::testOnResponseWithUncacheableResponse in core/
modules/ rest/ tests/ src/ Unit/ EventSubscriber/ ResourceResponseSubscriberTest.php - Tests on response with uncacheable response.
- ResourceResponseSubscriberTest::testResponseFormat in core/
modules/ rest/ tests/ src/ Unit/ EventSubscriber/ ResourceResponseSubscriberTest.php - Tests the response format.
File
-
core/
modules/ rest/ tests/ src/ Unit/ EventSubscriber/ ResourceResponseSubscriberTest.php, line 430
Class
Namespace
Drupal\Tests\rest\Unit\EventSubscriberCode
protected function generateRouteRequirements(array $supported_response_formats, array $supported_request_formats) : array {
$route_requirements = [
'_format' => implode('|', $supported_response_formats),
];
if (!empty($supported_request_formats)) {
$route_requirements['_content_type_format'] = implode('|', $supported_request_formats);
}
return $route_requirements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.