ApiPlatform\Core\JsonLd\Serializer\JsonLdContextTrait::addJsonLdContext PHP Method

addJsonLdContext() private method

Updates the given JSON-LD document to add its @context key.
private addJsonLdContext ( ApiPlatform\Core\JsonLd\ContextBuilderInterface $contextBuilder, string $resourceClass, array &$context, array $data = [] ) : array
$contextBuilder ApiPlatform\Core\JsonLd\ContextBuilderInterface
$resourceClass string
$context array
$data array
return array
    private function addJsonLdContext(ContextBuilderInterface $contextBuilder, string $resourceClass, array &$context, array $data = []) : array
    {
        if (isset($context['jsonld_has_context'])) {
            return $data;
        }
        $context['jsonld_has_context'] = true;
        if (isset($context['jsonld_embed_context'])) {
            $data['@context'] = $contextBuilder->getResourceContext($resourceClass);
            return $data;
        }
        $data['@context'] = $contextBuilder->getResourceContextUri($resourceClass);
        return $data;
    }
JsonLdContextTrait