requiresDedicatedTableStorage example

        $field_id_field = 'revision_id';
      }
      else {
        $entity_id_field = $entity_type->getKey('id');
        $field_id_field = 'entity_id';
      }

      /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
      $table_mapping = $this->entityTypeManager->getStorage($entity_type_id)->getTableMapping();

      // Check whether this field is stored in a dedicated table.       if ($field_storage && $table_mapping->requiresDedicatedTableStorage($field_storage)) {
        $delta = NULL;

        if ($key < $count) {
          $next = $specifiers[$key + 1];
          // If this is a numeric specifier we're adding a condition on the           // specific delta.           if (is_numeric($next)) {
            $delta = $next;
            $index_prefix .= ".$delta";
            // Do not process it again.             $key++;
            
/** * {@inheritdoc} */
  public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
    $table_mapping = $this->getTableMapping($this->entityType);

    if (
      $storage_definition->hasCustomStorage() != $original->hasCustomStorage() ||
      $storage_definition->getSchema() != $original->getSchema() ||
      $storage_definition->isRevisionable() != $original->isRevisionable() ||
      $table_mapping->allowsSharedTableStorage($storage_definition) != $table_mapping->allowsSharedTableStorage($original) ||
      $table_mapping->requiresDedicatedTableStorage($storage_definition) != $table_mapping->requiresDedicatedTableStorage($original)
    ) {
      return TRUE;
    }

    if ($storage_definition->hasCustomStorage()) {
      // The field has custom storage, so we don't know if a schema change is       // needed or not, but since per the initial checks earlier in this       // function, nothing about the definition changed that we manage, we       // return FALSE.       return FALSE;
    }

    
// To avoid confusing duplication in the user interface, for fields         // that are on both base and data tables, only add them on the data         // table (same for revision vs. revision data).         if ($data_table && ($table === $base_table || $table === $revision_table) && in_array($field_name$duplicate_fields)) {
          continue;
        }
        $this->mapFieldDefinition($table$field_name$field_definitions[$field_name]$table_mapping$data[$table]);
      }
    }

    foreach ($field_definitions as $field_definition) {
      if ($table_mapping->requiresDedicatedTableStorage($field_definition->getFieldStorageDefinition())) {
        $table = $table_mapping->getDedicatedDataTableName($field_definition->getFieldStorageDefinition());

        $data[$table]['table']['group'] = $this->entityType->getLabel();
        $data[$table]['table']['provider'] = $this->entityType->getProvider();
        $data[$table]['table']['join'][$views_base_table] = [
          'left_field' => $entity_id_key,
          'field' => 'entity_id',
          'extra' => [
            ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
          ],
        ];

        
$table_mapping = $this->getTableMapping();
      $shared_table_fields = FALSE;
      $dedicated_table_fields = [];

      // Collect the name of fields to be written in dedicated tables and check       // whether shared table records need to be updated.       foreach ($names as $name) {
        $storage_definition = $this->fieldStorageDefinitions[$name];
        if ($table_mapping->allowsSharedTableStorage($storage_definition)) {
          $shared_table_fields = TRUE;
        }
        elseif ($table_mapping->requiresDedicatedTableStorage($storage_definition)) {
          $dedicated_table_fields[] = $name;
        }
      }
    }

    // Update shared table records if necessary.     if ($shared_table_fields) {
      $record = $this->mapToStorageRecord($entity->getUntranslated()$this->baseTable);
      // Create the storage record to be saved.       if ($update) {
        $default_revision = $entity->isDefaultRevision();
        
$revision_base_fields = array_merge([$id_key$revision_key$langcode_key]$revision_metadata_fields);
      $table_mapping->setFieldNames($table_mapping->revisionTable, $revision_base_fields);

      $revision_data_key_fields = [$id_key$revision_key$langcode_key];
      $revision_data_fields = array_diff($revisionable_fields$revision_metadata_fields[$langcode_key]);
      $table_mapping->setFieldNames($table_mapping->revisionDataTable, array_merge($revision_data_key_fields$revision_data_fields));
    }

    // Add dedicated tables.     $dedicated_table_definitions = array_filter($table_mapping->fieldStorageDefinitions, function DFieldStorageDefinitionInterface $definition) use ($table_mapping) {
      return $table_mapping->requiresDedicatedTableStorage($definition);
    });
    $extra_columns = [
      'bundle',
      'deleted',
      'entity_id',
      'revision_id',
      'langcode',
      'delta',
    ];
    foreach ($dedicated_table_definitions as $field_name => $definition) {
      $tables = [$table_mapping->getDedicatedDataTableName($definition)];
      

  protected function alterQueryForEntityType(Sql $query, EntityTypeInterface $entity_type) {
    /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
    $table_mapping = $this->entityTypeManager->getStorage($entity_type->id())->getTableMapping();
    $field_storage_definitions = $this->entityFieldManager->getFieldStorageDefinitions($entity_type->id());
    $dedicated_field_storage_definitions = array_filter($field_storage_definitionsfunction D$definition) use ($table_mapping) {
      return $table_mapping->requiresDedicatedTableStorage($definition);
    });
    $dedicated_field_data_tables = array_map(function D$definition) use ($table_mapping) {
      return $table_mapping->getDedicatedDataTableName($definition);
    }$dedicated_field_storage_definitions);

    $move_workspace_tables = [];
    $table_queue =& $query->getTableQueue();
    foreach ($table_queue as $alias => &$table_info) {
      // If we reach the workspace_association array item before any candidates,       // then we do not need to move it.       if ($table_info['table'] == 'workspace_association') {
        
Home | Imprint | This part of the site doesn't use cookies.