comparison core/modules/content_moderation/src/ContentModerationStateStorageSchema.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
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 $schema['content_moderation_state_field_data']['unique keys'] += [
29 'content_moderation_state__lookup' => $unique_keys,
30 ];
31 $schema['content_moderation_state_field_revision']['unique keys'] += [
32 'content_moderation_state__lookup' => $unique_keys,
33 ];
34
35 return $schema;
36 }
37
38 }