class EntityReferenceFieldNormalizer extends FieldNormalizer (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.
 

Normalizer class specific for entity reference field objects.

Traits

SerializerAwareTrait

Properties

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

Methods

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.

static mixed
rasterizeValueRecursive(mixed $value)

Rasterizes a value recursively.

normalize($field, $format = NULL, array $context = [])

{@inheritdoc}

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

{@inheritdoc}

FieldItemNormalizerValue[]
normalizeFieldItems(FieldItemListInterface $field, string $format, array $context)

Helper function to normalize field items.

static array
getRelationshipLinks(ResourceObject $relationship_context, ResourceTypeRelationship $resource_relationship)

Gets the links for the relationship.

static bool
hasNonInternalResourceType(array $resource_types)

Determines if a given list of resource types contains a non-internal type.

Details

supportsNormalization($data, $format = NULL)

{@inheritdoc}

Parameters

$data
$format

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.

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.

normalize($field, $format = NULL, array $context = [])

{@inheritdoc}

Parameters

$field
$format
array $context

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

{@inheritdoc}

Parameters

$data
$class
$format
array $context

protected FieldItemNormalizerValue[] normalizeFieldItems(FieldItemListInterface $field, string $format, array $context)

Helper function to normalize field items.

Parameters

FieldItemListInterface $field

The field object.

string $format

The format.

array $context

The context array.

Return Value

FieldItemNormalizerValue[]

The array of normalized field items.

Gets the links for the relationship.

Parameters

ResourceObject $relationship_context

The JSON:API resource object context of the relationship.

ResourceTypeRelationship $resource_relationship

The resource type relationship field.

Return Value

array

The relationship's links.

static protected bool hasNonInternalResourceType(array $resource_types)

Determines if a given list of resource types contains a non-internal type.

Parameters

array $resource_types

The JSON:API resource types to evaluate.

Return Value

bool

FALSE if every resource type is internal, TRUE otherwise.