function ViewsConfigUpdater::getMultivalueBaseFieldUpdateTableInfo

Same name and namespace in other branches
  1. 8.9.x core/modules/views/src/ViewsConfigUpdater.php \Drupal\views\ViewsConfigUpdater::getMultivalueBaseFieldUpdateTableInfo()

Returns the multivalue base fields update table info.

Return value

array An array of multivalue base field info.

2 calls to ViewsConfigUpdater::getMultivalueBaseFieldUpdateTableInfo()
ViewsConfigUpdater::needsMultivalueBaseFieldUpdate in core/modules/views/src/ViewsConfigUpdater.php
Update field names for multi-value base fields.
ViewsConfigUpdater::processMultivalueBaseFieldHandler in core/modules/views/src/ViewsConfigUpdater.php
Processes handlers affected by the multivalue base field update.

File

core/modules/views/src/ViewsConfigUpdater.php, line 346

Class

ViewsConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\views

Code

protected function getMultivalueBaseFieldUpdateTableInfo() {
    $table_info =& $this->multivalueBaseFieldsUpdateTableInfo;
    if (!isset($table_info)) {
        $table_info = [];
        foreach ($this->entityTypeManager
            ->getDefinitions() as $entity_type_id => $entity_type) {
            if ($entity_type->hasHandlerClass('views_data') && $entity_type->entityClassImplements(FieldableEntityInterface::class)) {
                $base_field_definitions = $this->entityFieldManager
                    ->getBaseFieldDefinitions($entity_type_id);
                $entity_storage = $this->entityTypeManager
                    ->getStorage($entity_type_id);
                $table_mapping = $entity_storage->getTableMapping($base_field_definitions);
                if (!$table_mapping instanceof DefaultTableMapping) {
                    continue;
                }
                foreach ($base_field_definitions as $field_name => $base_field_definition) {
                    $base_field_storage_definition = $base_field_definition->getFieldStorageDefinition();
                    // Skip single value and custom storage base fields.
                    if (!$base_field_storage_definition->isMultiple() || $base_field_storage_definition->hasCustomStorage()) {
                        continue;
                    }
                    // Get the actual table, as well as the column for the main property
                    // name, so we can perform an update on the views in
                    // ::updateFieldNamesForMultivalueBaseFields().
                    $table_name = $table_mapping->getFieldTableName($field_name);
                    $main_property_name = $base_field_storage_definition->getMainPropertyName();
                    $table_info[$table_name][$field_name] = $table_mapping->getFieldColumnName($base_field_storage_definition, $main_property_name);
                }
            }
        }
    }
    return $table_info;
}

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