final class FormatSetter in JSON:API 8.2
Same name and namespace in other branches
- 8 src/StackMiddleware/FormatSetter.php \Drupal\jsonapi\StackMiddleware\FormatSetter
Sets the 'api_json' for requests with a JSON:API Content-Type header.
@internal JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it.
Hierarchy
- class \Drupal\jsonapi\StackMiddleware\FormatSetter implements \Symfony\Component\HttpKernel\HttpKernelInterface
Expanded class hierarchy of FormatSetter
See also
https://www.drupal.org/project/jsonapi/issues/3032787
1 string reference to 'FormatSetter'
1 service uses FormatSetter
File
- src/
StackMiddleware/ FormatSetter.php, line 18
Namespace
Drupal\jsonapi\StackMiddlewareView source
final class FormatSetter implements HttpKernelInterface {
/**
* The wrapped HTTP kernel.
*
* @var \Symfony\Component\HttpKernel\HttpKernelInterface
*/
protected $httpKernel;
/**
* Constructs a FormatSetter object.
*
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
* The decorated kernel.
*/
public function __construct(HttpKernelInterface $http_kernel) {
$this->httpKernel = $http_kernel;
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
$accepted = AcceptHeader::fromString($request->headers
->get('Accept'));
if ($accepted
->get('application/vnd.api+json')) {
$request
->setRequestFormat('api_json');
}
return $this->httpKernel
->handle($request, $type, $catch);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormatSetter:: |
protected | property | The wrapped HTTP kernel. | |
FormatSetter:: |
public | function | Handles a Request to convert it to a Response. | |
FormatSetter:: |
public | function | Constructs a FormatSetter object. |