You are here

protected function MappedObjectStorageSchema::getEntitySchema in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_mapping/src/MappedObjectStorageSchema.php \Drupal\salesforce_mapping\MappedObjectStorageSchema::getEntitySchema()
  2. 8.3 modules/salesforce_mapping/src/MappedObjectStorageSchema.php \Drupal\salesforce_mapping\MappedObjectStorageSchema::getEntitySchema()

Gets the entity schema for the specified entity type.

Entity types may override this method in order to optimize the generated schema of the entity tables. However, only cross-field optimizations should be added here; e.g., an index spanning multiple fields. Optimizations that apply to a single field have to be added via SqlContentEntityStorageSchema::getSharedTableFieldSchema() instead.

Parameters

\Drupal\Core\Entity\ContentEntityTypeInterface $entity_type: The entity type definition.

bool $reset: (optional) If set to TRUE static cache will be ignored and a new schema array generation will be performed. Defaults to FALSE.

Return value

array A Schema API array describing the entity schema, excluding dedicated field tables.

Overrides SqlContentEntityStorageSchema::getEntitySchema

File

modules/salesforce_mapping/src/MappedObjectStorageSchema.php, line 17

Class

MappedObjectStorageSchema
Defines the mapped object schema handler in order to add some unique keys.

Namespace

Drupal\salesforce_mapping

Code

protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
  $schema = parent::getEntitySchema($entity_type, $reset);

  // Backwards compatibility for salesforce_mapping_update_8001
  // key is too long if length is 255, so we have to wait until the db update
  // fires to avoid WSOD.
  $schema['salesforce_mapped_object']['unique keys'] += [
    'entity__mapping' => [
      'drupal_entity__target_type',
      'salesforce_mapping',
      'drupal_entity__target_id',
    ],
  ];
  $schema['salesforce_mapped_object']['unique keys'] += [
    'sfid__mapping' => [
      'salesforce_mapping',
      'salesforce_id',
    ],
  ];
  $schema['salesforce_mapped_object']['fields']['salesforce_mapping']['length'] = $schema['salesforce_mapped_object_revision']['fields']['salesforce_mapping']['length'] = EntityTypeInterface::ID_MAX_LENGTH;
  return $schema;
}