You are here

protected function YamlFormSubmissionStorageSchema::getEntitySchema in YAML Form 8

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/YamlFormSubmissionStorageSchema.php, line 16

Class

YamlFormSubmissionStorageSchema
Defines the form submission schema handler.

Namespace

Drupal\yamlform

Code

protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
  $schema = parent::getEntitySchema($entity_type, $reset = FALSE);
  $schema['yamlform_submission_data'] = [
    'description' => 'Stores all submitted data for form submissions.',
    'fields' => [
      'yamlform_id' => [
        'description' => 'The form 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' => [
      'yamlform_id' => [
        'yamlform_id',
      ],
      'sid_yamlform_id' => [
        'sid',
        'yamlform_id',
      ],
    ],
  ];
  return $schema;
}