References ContextBuilder
Reference
C
Class

ApiPlatform\JsonLd\ContextBuilder

JSON-LD context builder with Input Output DTO support interface.

class ApiPlatform\JsonLd\ContextBuilder implements , `<a href="/docs/main/references/JsonLd/ContextBuilderInterface">ApiPlatform\JsonLd\ContextBuilderInterface
{
    public __construct($resourceNameCollectionFactory, `<a href="/docs/main/references/Metadata/Resource/Factory/ResourceMetadataCollectionFactoryInterface">ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface</a>` $resourceMetadataFactory, `<a href="/docs/main/references/Metadata/Property/Factory/PropertyNameCollectionFactoryInterface">ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface</a>` $propertyNameCollectionFactory, `<a href="/docs/main/references/Metadata/Property/Factory/PropertyMetadataFactoryInterface">ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface</a>` $propertyMetadataFactory, `<a href="/docs/main/references/Api/UrlGeneratorInterface">ApiPlatform\Metadata\UrlGeneratorInterface</a>` $urlGenerator, null|`<a href="/docs/main/references/Api/IriConverterInterface">ApiPlatform\Metadata\IriConverterInterface $iriConverter, null|Symfony\Component\Serializer\NameConverter\NameConverterInterface $nameConverter)
    public getBaseContext(int $referenceType): array
    public getEntrypointContext(int $referenceType): array
    public getResourceContext(string $resourceClass, int $referenceType): array
    public getResourceContextUri(string $resourceClass, null|int $referenceType): string
    public getAnonymousResourceContext(object $object, array $context, int $referenceType): array
}

Methods

__construct

Parameters

resourceNameCollectionFactory`ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface`
resourceMetadataFactory`ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface`
propertyNameCollectionFactory`ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface`
propertyMetadataFactory`ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface`
urlGenerator`ApiPlatform\Metadata\UrlGeneratorInterface`
iriConverter`ApiPlatform\Metadata\IriConverterInterface`
nameConverterSymfony\Component\Serializer\NameConverter\NameConverterInterface

getBaseContext

Gets the base context.Gets the base context.

public getBaseContext(int $referenceType): array

Parameters

referenceTypeint

Returns

array

getEntrypointContext

Builds the JSON-LD context for the entrypoint.Builds the JSON-LD context for the entrypoint.

public getEntrypointContext(int $referenceType): array

Parameters

referenceTypeint

Returns

array

getResourceContext

Builds the JSON-LD context for the given resource.Builds the JSON-LD context for the given resource.

public getResourceContext(string $resourceClass, int $referenceType): array

Parameters

resourceClassstring
referenceTypeint

Returns

array

getResourceContextUri

Gets the URI of the given resource context.Gets the URI of the given resource context.

public getResourceContextUri(string $resourceClass, null|int $referenceType): string

Parameters

resourceClassstring
referenceTypeint

Returns

string

getAnonymousResourceContext

Creates a JSON-LD context based on the given object. Usually this is used with an Input or Output DTO object.

public getAnonymousResourceContext(object $object, array $context, int $referenceType): array

Parameters

objectobject
contextarray
referenceTypeint

Returns

array

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