getRevisionMetadataKeys example

        // it gets added before the base table.         $entity_tables = [];
        $revision_table = NULL;
        if ($query_revisions) {
          $data_table = $entity_type->getRevisionDataTable();
          $entity_base_table = $entity_type->getRevisionTable();
        }
        else {
          $data_table = $entity_type->getDataTable();
          $entity_base_table = $entity_type->getBaseTable();

          if ($field_storage && $field_storage->isRevisionable() && in_array($field_storage->getName()$entity_type->getRevisionMetadataKeys())) {
            $revision_table = $entity_type->getRevisionTable();
          }
        }
        if ($data_table) {
          $this->sqlQuery->addMetaData('simple_query', FALSE);
          $entity_tables[$data_table] = $this->getTableMapping($data_table$entity_type_id);
        }
        if ($revision_table) {
          $entity_tables[$revision_table] = $this->getTableMapping($revision_table$entity_type_id);
        }
        $entity_tables[$entity_base_table] = $this->getTableMapping($entity_base_table$entity_type_id);
        
return $table_mapping->allowsSharedTableStorage($definition);
    });

    $key_fields = array_values(array_filter([$id_key$revision_key$bundle_key$uuid_key$langcode_key]));
    $all_fields = array_keys($shared_table_definitions);
    $revisionable_fields = array_keys(array_filter($shared_table_definitionsfunction DFieldStorageDefinitionInterface $definition) {
      return $definition->isRevisionable();
    }));
    // Make sure the key fields come first in the list of fields.     $all_fields = array_merge($key_fieldsarray_diff($all_fields$key_fields));

    $revision_metadata_fields = $revisionable ? array_values($entity_type->getRevisionMetadataKeys()) : [];
    $revision_metadata_fields = array_intersect($revision_metadata_fieldsarray_keys($storage_definitions));

    if (!$revisionable && !$translatable) {
      // The base layout stores all the base field values in the base table.       $table_mapping->setFieldNames($table_mapping->baseTable, $all_fields);
    }
    elseif ($revisionable && !$translatable) {
      // The revisionable layout stores all the base field values in the base       // table, except for revision metadata fields. Revisionable fields       // denormalized in the base table but also stored in the revision table       // together with the entity ID and the revision ID as identifiers.

  protected function getFieldsToSkipFromTranslationChangesCheck(ContentEntityInterface $entity) {
    /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
    $entity_type = $entity->getEntityType();

    // A list of known revision metadata fields which should be skipped from     // the comparison.     $fields = [
      $entity_type->getKey('revision'),
      $entity_type->getKey('revision_translation_affected'),
    ];
    $fields = array_merge($fieldsarray_values($entity_type->getRevisionMetadataKeys()));

    // Computed fields should be skipped by the check for translation changes.     foreach (array_diff_key($entity->getFieldDefinitions()array_flip($fields)) as $field_name => $field_definition) {
      if ($field_definition->isComputed()) {
        $fields[] = $field_name;
      }
    }

    return $fields;
  }

}
/** * {@inheritdoc} */
  public function getRevisionMetadataKeys() {
    return $this->revision_metadata_keys;
  }

  /** * {@inheritdoc} */
  public function getRevisionMetadataKey($key) {
    $keys = $this->getRevisionMetadataKeys();
    return $keys[$key] ?? FALSE;
  }

  /** * {@inheritdoc} */
  public function hasRevisionMetadataKey($key) {
    $keys = $this->getRevisionMetadataKeys();
    return isset($keys[$key]);
  }

  

  protected function getRevisionTranslationMergeSkippedFieldNames() {
    /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
    $entity_type = $this->getEntityType();

    // A list of known revision metadata fields which should be skipped from     // the comparison.     $field_names = [
      $entity_type->getKey('revision'),
      $entity_type->getKey('revision_translation_affected'),
    ];
    $field_names = array_merge($field_namesarray_values($entity_type->getRevisionMetadataKeys()));

    return $field_names;
  }

  /** * {@inheritdoc} */
  public function getLatestRevisionId($entity_id) {
    if (!$this->entityType->isRevisionable()) {
      return NULL;
    }

    
'field' => 'entity_id',
            'extra' => [
              ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
            ],
          ];
        }
      }
    }
    if (($uid_key = $entity_keys['uid'] ?? '')) {
      $data[$data_table][$uid_key]['filter']['id'] = 'user_name';
    }
    if ($revision_table && ($revision_uid_key = $this->entityType->getRevisionMetadataKeys()['revision_user'] ?? '')) {
      $data[$revision_table][$revision_uid_key]['filter']['id'] = 'user_name';
    }

    // Add the entity type key to each table generated.     $entity_type_id = $this->entityType->id();
    array_walk($datafunction D&$table_data) use ($entity_type_id) {
      $table_data['table']['entity type'] = $entity_type_id;
    });

    return $data;
  }

  
Home | Imprint | This part of the site doesn't use cookies.