References AddFormatListener
Reference
C
Class

ApiPlatform\Symfony\EventListener\AddFormatListener

Chooses the format to use according to the Accept header and supported formats.

class ApiPlatform\Symfony\EventListener\AddFormatListener
{
    public __construct(|Negotiation\Negotiator $negotiator, null|`<a href="/docs/main/references/Metadata/Resource/Factory/ResourceMetadataCollectionFactoryInterface">ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, array $formats, array $errorFormats, array $docsFormats, null|bool $eventsBackwardCompatibility)
    public onKernelRequest(Symfony\Component\HttpKernel\Event\RequestEvent $event): null
    public setRequestErrorFormat(null|ApiPlatform\Metadata\HttpOperation $operation, Symfony\Component\HttpFoundation\Request $request): null
}

Methods

__construct

public __construct(|Negotiation\Negotiator $negotiator, null|`<a href="/docs/main/references/Metadata/Resource/Factory/ResourceMetadataCollectionFactoryInterface">ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, array $formats, array $errorFormats, array $docsFormats, null|bool $eventsBackwardCompatibility)

Parameters

negotiator`ApiPlatform\State\ProviderInterface`
Negotiation\Negotiator
resourceMetadataCollectionFactory`ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface`
formatsarray
errorFormatsarray
docsFormatsarray
eventsBackwardCompatibilitybool

onKernelRequest

Sets the applicable format to the HttpFoundation Request.

public onKernelRequest(Symfony\Component\HttpKernel\Event\RequestEvent $event): null

Parameters

eventSymfony\Component\HttpKernel\Event\RequestEvent

Returns

null

setRequestErrorFormat

public setRequestErrorFormat(null|ApiPlatform\Metadata\HttpOperation $operation, Symfony\Component\HttpFoundation\Request $request): null

Parameters

operation`ApiPlatform\Metadata\HttpOperation`
requestSymfony\Component\HttpFoundation\Request

Returns

null

Made with love by

Les-Tilleuls.coop can help you design and develop your APIs and web projects, and train your teams in API Platform, Symfony, Next.js, Kubernetes and a wide range of other technologies.

Learn more

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop