You are here

protected function WebformSubmissionStorageSchema::getEntitySchema in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionStorageSchema.php \Drupal\webform\WebformSubmissionStorageSchema::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

src/WebformSubmissionStorageSchema.php, line 16

Class

WebformSubmissionStorageSchema
Defines the webform submission schema handler.

Namespace

Drupal\webform

Code

protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
  $schema = parent::getEntitySchema($entity_type, $reset);
  $schema['webform_submission']['indexes'] += [
    'webform_submission_field__token' => [
      'token',
    ],
  ];
  $schema['webform_submission_data'] = [
    'description' => 'Stores all submitted data for webform submissions.',
    'fields' => [
      'webform_id' => [
        'description' => 'The webform id.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ],
      'sid' => [
        'description' => 'The unique identifier for this submission.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'name' => [
        'description' => 'The name of the element.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ],
      'property' => [
        'description' => "The property of the element's value.",
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ],
      'delta' => [
        'description' => "The delta of the element's value.",
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'value' => [
        'description' => "The element's value.",
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
      ],
    ],
    'primary key' => [
      'sid',
      'name',
      'property',
      'delta',
    ],
    'indexes' => [
      'webform_id' => [
        'webform_id',
      ],
      'sid_webform_id' => [
        'sid',
        'webform_id',
      ],
    ],
  ];
  return $schema;
}