24754870458de875f4994d1c8b30afc479aad52d
[yaffs-website] / web / core / modules / content_moderation / src / ContentModerationStateStorageSchema.php
1 <?php
2
3 namespace Drupal\content_moderation;
4
5 use Drupal\Core\Entity\ContentEntityTypeInterface;
6 use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
7
8 /**
9  * Defines the content moderation state schema handler.
10  */
11 class ContentModerationStateStorageSchema extends SqlContentEntityStorageSchema {
12
13   /**
14    * {@inheritdoc}
15    */
16   protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
17     $schema = parent::getEntitySchema($entity_type, $reset);
18
19     // Creates unique keys to guarantee the integrity of the entity and to make
20     // the lookup in ModerationStateFieldItemList::getModerationState() fast.
21     $unique_keys = [
22       'content_entity_type_id',
23       'content_entity_id',
24       'content_entity_revision_id',
25       'workflow',
26       'langcode',
27     ];
28     if ($data_table = $this->storage->getDataTable()) {
29       $schema[$data_table]['unique keys'] += [
30         'content_moderation_state__lookup' => $unique_keys,
31       ];
32     }
33     if ($revision_data_table = $this->storage->getRevisionDataTable()) {
34       $schema[$revision_data_table]['unique keys'] += [
35         'content_moderation_state__lookup' => $unique_keys,
36       ];
37     }
38
39     return $schema;
40   }
41
42 }