function ResourceResponseSubscriberTest::generateRouteRequirements

Same name in other branches
  1. 9 core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php \Drupal\Tests\rest\Unit\EventSubscriber\ResourceResponseSubscriberTest::generateRouteRequirements()
  2. 10 core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php \Drupal\Tests\rest\Unit\EventSubscriber\ResourceResponseSubscriberTest::generateRouteRequirements()
  3. 11.x 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 417

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;
}

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