You are here

protected function SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/serialization/src/Normalizer/SerializedColumnNormalizerTrait.php \Drupal\serialization\Normalizer\SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames()

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.

Parameters

\Drupal\Core\Field\FieldItemInterface $field_item: The field item.

Return value

string[] The property names for serialized properties.

2 calls to SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames()
FieldItemNormalizer::denormalize in core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php
Denormalizes data back into an object of the given class.
PrimitiveDataNormalizer::normalize in core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php
Normalizes an object into a set of arrays/scalars.

File

core/modules/serialization/src/Normalizer/SerializedColumnNormalizerTrait.php, line 101

Class

SerializedColumnNormalizerTrait
A trait providing methods for serialized columns.

Namespace

Drupal\serialization\Normalizer

Code

protected function getCustomSerializedPropertyNames(FieldItemInterface $field_item) {
  if ($field_item instanceof PluginInspectionInterface) {
    $definition = $field_item
      ->getPluginDefinition();
    $serialized_fields = $field_item
      ->getEntity()
      ->getEntityType()
      ->get('serialized_field_property_names');
    $field_name = $field_item
      ->getFieldDefinition()
      ->getName();
    if (is_array($serialized_fields) && isset($serialized_fields[$field_name]) && is_array($serialized_fields[$field_name])) {
      return $serialized_fields[$field_name];
    }
    if (isset($definition['serialized_property_names']) && is_array($definition['serialized_property_names'])) {
      return $definition['serialized_property_names'];
    }
  }
  return [];
}