EntityReferenceItemNormalizer
class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidReferenceInterface (View source)
Converts the Drupal entity reference item object to HAL array structure.
Traits
Converts empty reference values for entity reference items.
A trait for providing fieldable entity normalization/denormalization methods.
A trait providing methods for serialized columns.
Properties
| protected | $supportedInterfaceOrClass | {@inheritdoc} | |
| protected | $format | {@inheritdoc} | from NormalizerBase |
| protected EntityFieldManagerInterface | $entityFieldManager | The entity field manager. |
from FieldableEntityNormalizerTrait |
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected EntityTypeRepositoryInterface | $entityTypeRepository | The entity type repository. |
from FieldableEntityNormalizerTrait |
| protected LinkManagerInterface | $linkManager | The hypermedia link manager. |
|
| protected EntityResolverInterface | $entityResolver | The entity resolver. |
Methods
Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization()
Checks if the provided format is supported by this normalizer.
Determines the entity type ID to denormalize as.
Gets the entity type definition.
Denormalizes the bundle property so entity creation can use it.
Denormalizes entity data by denormalizing each field individually.
Returns the entity type repository.
Returns the entity field manager.
Returns the entity type manager.
Build the field item value using the incoming data.
Checks if there is a serialized string for a column.
Checks if the data contains string value for serialize column.
Gets the names of all serialized properties.
Gets the names of all properties the plugin treats as serialized data.
{@inheritdoc}
{@inheritdoc}
Normalizes field values for an item.
Get a translated version of the field item instance.
Determines if a field item references a taxonomy term.
Constructs an EntityReferenceItemNormalizer object.
Checks whether the referenced entity is of a fieldable entity type.
Get the uuid from the data array.
Details
supportsNormalization($data, $format = NULL)
{@inheritdoc}
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.
protected bool
checkFormat(string $format = NULL)
Checks if the provided format is supported by this normalizer.
protected
addCacheableDependency(array $context, $data)
Adds cacheability if applicable.
protected string
determineEntityTypeId(string $class, array $context)
Determines the entity type ID to denormalize as.
protected EntityTypeInterface
getEntityTypeDefinition(string $entity_type_id)
Gets the entity type definition.
protected string
extractBundleData(array $data, EntityTypeInterface $entity_type_definition)
Denormalizes the bundle property so entity creation can use it.
protected
denormalizeFieldData(array $data, FieldableEntityInterface $entity, string $format, array $context)
Denormalizes entity data by denormalizing each field individually.
protected EntityTypeRepositoryInterface
getEntityTypeRepository()
Returns the entity type repository.
protected EntityFieldManagerInterface
getEntityFieldManager()
Returns the entity field manager.
protected EntityTypeManagerInterface
getEntityTypeManager()
Returns the entity type manager.
protected mixed
constructValue(mixed $data, array $context)
Build the field item value using the incoming data.
Most normalizers that extend this class can simply use this method to construct the denormalized value without having to override denormalize() and reimplementing its validation logic or its call to set the field value.
It's recommended to not override this and instead provide a (de)normalizer at the DataType level.
protected
checkForSerializedStrings(mixed $data, string $class, FieldItemInterface $field_item)
Checks if there is a serialized string for a column.
protected bool
dataHasStringForSerializeColumn(FieldItemInterface $field_item, array $data)
Checks if the data contains string value for serialize column.
protected string[]
getSerializedPropertyNames(FieldItemInterface $field_item)
Gets the names of all serialized properties.
protected string[]
getCustomSerializedPropertyNames(FieldItemInterface $field_item)
Gets the names of all properties the plugin treats as serialized data.
This allows the field storage definition or entity type to provide a setting for serialized properties. This can be used for fields that handle serialized data themselves and do not rely on the serialized schema flag.
normalize($field_item, $format = NULL, array $context = [])
{@inheritdoc}
denormalize($data, $class, $format = NULL, array $context = [])
{@inheritdoc}
protected array
normalizedFieldValues(FieldItemInterface $field_item, string|null $format, array $context)
Normalizes field values for an item.
protected FieldItemInterface
createTranslatedInstance(FieldItemInterface $item, $langcode)
Get a translated version of the field item instance.
To indicate that a field item applies to one translation of an entity and not another, the property path must originate with a translation of the entity. This is the reason for using target_instances, from which the property path can be traversed up to the root.
protected
normalizeRootReferenceValue($values, EntityReferenceItem $field_item)
No description
protected bool
fieldItemReferencesTaxonomyTerm(EntityReferenceItem $field_item)
Determines if a field item references a taxonomy term.
__construct(LinkManagerInterface $link_manager, EntityResolverInterface $entity_Resolver, EntityTypeManagerInterface $entity_type_manager = NULL)
Constructs an EntityReferenceItemNormalizer object.
protected bool
targetEntityIsFieldable(EntityReferenceItem $item)
Checks whether the referenced entity is of a fieldable entity type.
string
getUuid(array $data)
Get the uuid from the data array.