You are here

protected function ResourceResponseSubscriberTest::generateRouteRequirements in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php \Drupal\Tests\rest\Unit\EventSubscriber\ResourceResponseSubscriberTest::generateRouteRequirements()
  2. 9 core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php \Drupal\Tests\rest\Unit\EventSubscriber\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
@covers ::onResponse @covers ::getResponseFormat @covers ::renderResponseBody @covers ::flattenResponse
ResourceResponseSubscriberTest::testOnResponseWithUncacheableResponse in core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
@covers ::onResponse @covers ::getResponseFormat @covers ::renderResponseBody @covers ::flattenResponse
ResourceResponseSubscriberTest::testResponseFormat in core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
@covers ::getResponseFormat

File

core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php, line 418

Class

ResourceResponseSubscriberTest
@coversDefaultClass \Drupal\rest\EventSubscriber\ResourceResponseSubscriber @group rest

Namespace

Drupal\Tests\rest\Unit\EventSubscriber

Code

protected function generateRouteRequirements(array $supported_response_formats, array $supported_request_formats) {
  $route_requirements = [
    '_format' => implode('|', $supported_response_formats),
  ];
  if (!empty($supported_request_formats)) {
    $route_requirements['_content_type_format'] = implode('|', $supported_request_formats);
  }
  return $route_requirements;
}