function SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames

Same name in other branches
  1. 8.9.x core/modules/serialization/src/Normalizer/SerializedColumnNormalizerTrait.php \Drupal\serialization\Normalizer\SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames()
  2. 10 core/modules/serialization/src/Normalizer/SerializedColumnNormalizerTrait.php \Drupal\serialization\Normalizer\SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames()
  3. 11.x 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.

3 calls to SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames()
FieldItemNormalizer::denormalize in core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php
PrimitiveDataNormalizer::normalize in core/modules/serialization/src/Normalizer/PrimitiveDataNormalizer.php
SerializedColumnNormalizerTrait::getSerializedPropertyNames in core/modules/serialization/src/Normalizer/SerializedColumnNormalizerTrait.php
Gets the names of all serialized properties.

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 [];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.