class CommentStorageSchema in Drupal 9
Same name and namespace in other branches
- 8 core/modules/comment/src/CommentStorageSchema.php \Drupal\comment\CommentStorageSchema
Defines the comment schema handler.
Hierarchy
- class \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorageSchemaInterface uses DependencySerializationTrait, SqlFieldableEntityTypeListenerTrait
- class \Drupal\comment\CommentStorageSchema
Expanded class hierarchy of CommentStorageSchema
File
- core/
modules/ comment/ src/ CommentStorageSchema.php, line 13
Namespace
Drupal\commentView source
class CommentStorageSchema extends SqlContentEntityStorageSchema {
/**
* {@inheritdoc}
*/
protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
$schema = parent::getEntitySchema($entity_type, $reset);
if ($data_table = $this->storage
->getDataTable()) {
$schema[$data_table]['indexes'] += [
'comment__status_pid' => [
'pid',
'status',
],
'comment__num_new' => [
'entity_id',
'entity_type',
'comment_type',
'status',
'created',
'cid',
'thread',
],
'comment__entity_langcode' => [
'entity_id',
'entity_type',
'comment_type',
'default_langcode',
],
];
}
return $schema;
}
/**
* {@inheritdoc}
*/
protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
$schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
$field_name = $storage_definition
->getName();
if ($table_name == 'comment_field_data') {
// Remove unneeded indexes.
unset($schema['indexes']['comment_field__pid__target_id']);
unset($schema['indexes']['comment_field__entity_id__target_id']);
switch ($field_name) {
case 'thread':
// Improves the performance of the comment__num_new index defined
// in getEntitySchema().
$schema['fields'][$field_name]['not null'] = TRUE;
break;
case 'entity_type':
case 'field_name':
assert($storage_definition instanceof RequiredFieldStorageDefinitionInterface);
if ($storage_definition
->isStorageRequired()) {
// The 'entity_type' and 'field_name' are required so they also need
// to be marked as NOT NULL.
$schema['fields'][$field_name]['not null'] = TRUE;
}
break;
case 'created':
$this
->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
break;
case 'uid':
$this
->addSharedTableFieldForeignKey($storage_definition, $schema, 'users', 'uid');
}
}
return $schema;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommentStorageSchema:: |
protected | function |
Gets the entity schema for the specified entity type. Overrides SqlContentEntityStorageSchema:: |
|
CommentStorageSchema:: |
protected | function |
Gets the schema for a single field definition. Overrides SqlContentEntityStorageSchema:: |
|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
SqlContentEntityStorageSchema:: |
protected | property | The database connection to be used. | |
SqlContentEntityStorageSchema:: |
protected | property | The deleted fields repository. | |
SqlContentEntityStorageSchema:: |
protected | property | The entity field manager service. | |
SqlContentEntityStorageSchema:: |
protected | property | The entity type this schema builder is responsible for. | |
SqlContentEntityStorageSchema:: |
protected | property | The entity type manager. | |
SqlContentEntityStorageSchema:: |
protected | property | The storage field definitions for this entity type. | |
SqlContentEntityStorageSchema:: |
protected | property | The key-value collection for tracking installed storage schema. | |
SqlContentEntityStorageSchema:: |
protected | property | A static cache of the generated schema array. | |
SqlContentEntityStorageSchema:: |
protected | property | The storage object for the given entity type. | |
SqlContentEntityStorageSchema:: |
protected | property | The key-value collection for tracking entity update backup repository. | |
SqlContentEntityStorageSchema:: |
protected | function | Creates an index, dropping it if already existing. | |
SqlContentEntityStorageSchema:: |
protected | function | Adds a foreign key for the specified field to the given schema definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Adds an index for the specified field to the given schema definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Adds a unique key for the specified field to the given schema definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Adds defaults to a table schema definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Creates a unique key, dropping it if already existing. | |
SqlContentEntityStorageSchema:: |
public static | function | Typecasts values to proper datatypes. | |
SqlContentEntityStorageSchema:: |
protected | function | Checks that we are dealing with the correct entity type. | |
SqlContentEntityStorageSchema:: |
protected | function | Creates the schema for a field stored in a dedicated table. | |
SqlContentEntityStorageSchema:: |
protected | function | Creates the specified entity schema indexes and keys. | |
SqlContentEntityStorageSchema:: |
protected | function | Creates the schema for a field stored in a shared table. | |
SqlContentEntityStorageSchema:: |
protected | function | Deletes the schema for a field stored in a dedicated table. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets the deleted fields repository. | |
SqlContentEntityStorageSchema:: |
protected | function | Deletes schema data for the given entity type definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Deletes the specified entity schema indexes and keys. | |
SqlContentEntityStorageSchema:: |
protected | function | Deletes schema data for the given field storage definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Deletes the schema for a field stored in a shared table. | |
SqlContentEntityStorageSchema:: |
public | function |
Performs final cleanup after all data of a field has been purged. Overrides DynamicallyFieldableEntityStorageSchemaInterface:: |
|
SqlContentEntityStorageSchema:: |
protected | function | Returns a list of column schema keys affecting data storage. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets the SQL schema for a dedicated table. | 1 |
SqlContentEntityStorageSchema:: |
protected | function | Gets the name to be used for the given entity index. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets entity schema definitions for index and key definitions. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets a list of entity type tables. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets field foreign keys. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets an index schema array for a given field. | |
SqlContentEntityStorageSchema:: |
protected | function | Generates an index name for a field data table. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets field schema data for the given key. | |
SqlContentEntityStorageSchema:: |
protected | function | Generates a safe schema identifier (name of an index, column name etc.). | |
SqlContentEntityStorageSchema:: |
protected | function | Gets a unique key schema array for a given field. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets the schema data for the given field storage definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Returns a SELECT query suitable for inserting data into a dedicated table. | |
SqlContentEntityStorageSchema:: |
protected | function | Refreshes the table mapping with updated definitions. | |
SqlContentEntityStorageSchema:: |
private | function | Gets a list of table names for this entity type, field storage and mapping. | |
SqlContentEntityStorageSchema:: |
public static | function | Gets a string to be used as a prefix for a temporary table mapping object. | |
SqlContentEntityStorageSchema:: |
protected | function |
Handles the case when an error occurs during the data copying step. Overrides SqlFieldableEntityTypeListenerTrait:: |
|
SqlContentEntityStorageSchema:: |
protected | function | Compares schemas to check for changes in the column definitions. | |
SqlContentEntityStorageSchema:: |
protected | function | Checks whether a field property has NULL values. | |
SqlContentEntityStorageSchema:: |
protected | function | Detects whether any table name got renamed in an entity type update. | |
SqlContentEntityStorageSchema:: |
protected | function | Detects whether there is a change in the shared table structure. | |
SqlContentEntityStorageSchema:: |
protected | function | Initializes common information for a base table. | |
SqlContentEntityStorageSchema:: |
protected | function | Initializes common information for a data table. | |
SqlContentEntityStorageSchema:: |
protected | function | Initializes common information for a revision data table. | |
SqlContentEntityStorageSchema:: |
protected | function | Initializes common information for a revision table. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets the keyvalue collection for tracking the installed schema. | |
SqlContentEntityStorageSchema:: |
protected | function | Checks whether a database table is non-existent or empty. | |
SqlContentEntityStorageSchema:: |
protected | function | Loads stored schema data for the given entity type definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Loads stored schema data for the given field storage definition. | |
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the creation of the entity type. Overrides EntityTypeListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the deletion of the entity type. Overrides EntityTypeListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the update of the entity type. Overrides EntityTypeListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the creation of the fieldable entity type. Overrides EntityTypeListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the update of a fieldable entity type. Overrides EntityTypeListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the creation of a field storage definition. Overrides FieldStorageDefinitionListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the deletion of a field storage definition. Overrides FieldStorageDefinitionListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Reacts to the update of a field storage definition. Overrides FieldStorageDefinitionListenerInterface:: |
|
SqlContentEntityStorageSchema:: |
protected | function | Performs the specified operation on a field. | |
SqlContentEntityStorageSchema:: |
protected | function |
Allows subscribers to do any cleanup necessary after data copying. Overrides SqlFieldableEntityTypeListenerTrait:: |
|
SqlContentEntityStorageSchema:: |
protected | function |
Allows subscribers to prepare their schema before data copying. Overrides SqlFieldableEntityTypeListenerTrait:: |
|
SqlContentEntityStorageSchema:: |
protected | function | Processes the gathered schema for a base table. | |
SqlContentEntityStorageSchema:: |
protected | function | Processes the schema for a field storage definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Processes the specified entity key. | |
SqlContentEntityStorageSchema:: |
protected | function | Processes the gathered schema for a base table. | |
SqlContentEntityStorageSchema:: |
public | function |
Checks if existing data would be lost if the schema changes were applied. Overrides EntityStorageSchemaInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Checks if the changes to the entity type requires storage schema changes. Overrides EntityStorageSchemaInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Checks if existing data would be lost if the schema changes were applied. Overrides DynamicallyFieldableEntityStorageSchemaInterface:: |
|
SqlContentEntityStorageSchema:: |
public | function |
Checks if the changes to the storage definition requires schema changes. Overrides DynamicallyFieldableEntityStorageSchemaInterface:: |
|
SqlContentEntityStorageSchema:: |
protected | function | Stores schema data for the given entity type definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Stores schema data for the given field storage definition. | |
SqlContentEntityStorageSchema:: |
protected | function | Gets the key/value collection for tracking the entity update backups. | |
SqlContentEntityStorageSchema:: |
protected | function | Updates the schema for a field stored in a shared table. | |
SqlContentEntityStorageSchema:: |
protected | function | Updates the schema for a field stored in a shared table. | |
SqlContentEntityStorageSchema:: |
public | function | Constructs a SqlContentEntityStorageSchema. | |
SqlFieldableEntityTypeListenerTrait:: |
protected | function | Copies entity data from the original storage to the temporary one. | |
SqlFieldableEntityTypeListenerTrait:: |
public | function | Aliased as: traitOnFieldableEntityTypeUpdate |