class JsonApiDocumentTopLevelNormalizer extends NormalizerBase implements DenormalizerInterface, NormalizerInterface (View source)

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.
 

Normalizes the top-level document according to the JSON:API specification.

Traits

SerializerAwareTrait

Properties

protected $supportedInterfaceOrClass {@inheritdoc}
protected $format {@inheritdoc} from  NormalizerBase
protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

protected ResourceTypeRepositoryInterface $resourceTypeRepository

The JSON:API resource type repository.

Methods

bool
supportsNormalization($data, $format = NULL)

{@inheritdoc}

supportsDenormalization($data, $type, $format = NULL)

Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

bool
checkFormat(string $format = NULL)

Checks if the provided format is supported by this normalizer.

addCacheableDependency(array $context, $data)

Adds cacheability if applicable.

bool
hasCacheableSupportsMethod()

{@inheritdoc}

static mixed
rasterizeValueRecursive(mixed $value)

Rasterizes a value recursively.

__construct(EntityTypeManagerInterface $entity_type_manager, ResourceTypeRepositoryInterface $resource_type_repository)

Constructs a JsonApiDocumentTopLevelNormalizer object.

mixed
denormalize($data, $class, $format = NULL, array $context = [])

{@inheritdoc}

array|string|int|float|bool|ArrayObject|null
normalize($object, $format = NULL, array $context = [])

{@inheritdoc}

normalizeErrorDocument(JsonApiDocumentTopLevel $document, string $format, array $context = [])

Normalizes an error collection.

normalizeOmissionsLinks(OmittedData $omissions, string $format, array $context = [])

Normalizes omitted data into a set of omission links.

static 
validateRequestBody(array $document, ResourceType $resource_type)

Performs minimal validation of the document.

static string
getLinkHash(string $salt, string $link_href)

Hashes an omitted link.

Details

bool supportsNormalization($data, $format = NULL)

{@inheritdoc}

Parameters

$data
$format

Return Value

bool

supportsDenormalization($data, $type, $format = NULL)

Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()

This class doesn't implement DenormalizerInterface, but most of its child classes do. Therefore, this method is implemented at this level to reduce code duplication.

Parameters

$data
$type
$format

protected bool checkFormat(string $format = NULL)

Checks if the provided format is supported by this normalizer.

Parameters

string $format

The format to check.

Return Value

bool

TRUE if the format is supported, FALSE otherwise. If no format is specified this will return TRUE.

protected addCacheableDependency(array $context, $data)

Adds cacheability if applicable.

Parameters

array $context

Context options for the normalizer.

$data

The data that might have cacheability information.

bool hasCacheableSupportsMethod()

{@inheritdoc}

Return Value

bool

static protected mixed rasterizeValueRecursive(mixed $value)

Rasterizes a value recursively.

This is mainly for configuration entities where a field can be a tree of values to rasterize.

Parameters

mixed $value

Either a scalar, an array or a rasterizable object.

Return Value

mixed

The rasterized value.

__construct(EntityTypeManagerInterface $entity_type_manager, ResourceTypeRepositoryInterface $resource_type_repository)

Constructs a JsonApiDocumentTopLevelNormalizer object.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

ResourceTypeRepositoryInterface $resource_type_repository

The JSON:API resource type repository.

mixed denormalize($data, $class, $format = NULL, array $context = [])

{@inheritdoc}

Parameters

$data
$class
$format
array $context

Return Value

mixed

array|string|int|float|bool|ArrayObject|null normalize($object, $format = NULL, array $context = [])

{@inheritdoc}

Parameters

$object
$format
array $context

Return Value

array|string|int|float|bool|ArrayObject|null

protected CacheableNormalization normalizeErrorDocument(JsonApiDocumentTopLevel $document, string $format, array $context = [])

Normalizes an error collection.

Parameters

JsonApiDocumentTopLevel $document

The document to normalize.

string $format

The normalization format.

array $context

The normalization context.

Return Value

CacheableNormalization

The normalized document.

Normalizes omitted data into a set of omission links.

Parameters

OmittedData $omissions

The omitted response data.

string $format

The normalization format.

array $context

The normalization context.

Return Value

CacheableNormalization|CacheableOmission

The normalized omissions.

static protected validateRequestBody(array $document, ResourceType $resource_type)

Performs minimal validation of the document.

Parameters

array $document
ResourceType $resource_type

static protected string getLinkHash(string $salt, string $link_href)

Hashes an omitted link.

Parameters

string $salt

A hash salt.

string $link_href

The omitted link.

Return Value

string

A 7 character hash.