You are here

protected function SerializedColumnNormalizerTrait::getSerializedPropertyNames in Drupal 10

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

Gets the names of all serialized properties.

Parameters

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

Return value

string[] The property names for serialized properties.

2 calls to SerializedColumnNormalizerTrait::getSerializedPropertyNames()
SerializedColumnNormalizerTrait::checkForSerializedStrings in core/modules/serialization/src/Normalizer/SerializedColumnNormalizerTrait.php
Checks if there is a serialized string for a column.
SerializedColumnNormalizerTrait::dataHasStringForSerializeColumn in core/modules/serialization/src/Normalizer/SerializedColumnNormalizerTrait.php
Checks if the data contains string value for serialize column.

File

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

Class

SerializedColumnNormalizerTrait
A trait providing methods for serialized columns.

Namespace

Drupal\serialization\Normalizer

Code

protected function getSerializedPropertyNames(FieldItemInterface $field_item) {
  $field_storage_definition = $field_item
    ->getFieldDefinition()
    ->getFieldStorageDefinition();
  if ($custom_property_names = $this
    ->getCustomSerializedPropertyNames($field_item)) {
    return $custom_property_names;
  }
  $field_storage_schema = $field_item
    ->schema($field_storage_definition);

  // If there are no columns then there are no serialized properties.
  if (!isset($field_storage_schema['columns'])) {
    return [];
  }
  $serialized_columns = array_filter($field_storage_schema['columns'], function ($column_schema) {
    return isset($column_schema['serialize']) && $column_schema['serialize'] === TRUE;
  });
  return array_keys($serialized_columns);
}