function Importer::getCustomSerializedPropertyNames

Same name in other branches
  1. 10 core/lib/Drupal/Core/DefaultContent/Importer.php \Drupal\Core\DefaultContent\Importer::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.

See also

\Drupal\serialization\Normalizer\SerializedColumnNormalizerTrait::getCustomSerializedPropertyNames

1 call to Importer::getCustomSerializedPropertyNames()
Importer::setFieldValues in core/lib/Drupal/Core/DefaultContent/Importer.php
Sets field values based on the normalized data.

File

core/lib/Drupal/Core/DefaultContent/Importer.php, line 304

Class

Importer
A service for handling import of content.

Namespace

Drupal\Core\DefaultContent

Code

private function getCustomSerializedPropertyNames(FieldItemInterface $field_item) : array {
    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.