Mercurial > hg > isophonics-drupal-site
annotate core/modules/content_moderation/src/ContentModerationStateStorageSchema.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\content_moderation; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Entity\ContentEntityTypeInterface; |
Chris@0 | 6 use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema; |
Chris@0 | 7 |
Chris@0 | 8 /** |
Chris@0 | 9 * Defines the content moderation state schema handler. |
Chris@0 | 10 */ |
Chris@0 | 11 class ContentModerationStateStorageSchema extends SqlContentEntityStorageSchema { |
Chris@0 | 12 |
Chris@0 | 13 /** |
Chris@0 | 14 * {@inheritdoc} |
Chris@0 | 15 */ |
Chris@0 | 16 protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) { |
Chris@0 | 17 $schema = parent::getEntitySchema($entity_type, $reset); |
Chris@0 | 18 |
Chris@0 | 19 // Creates unique keys to guarantee the integrity of the entity and to make |
Chris@0 | 20 // the lookup in ModerationStateFieldItemList::getModerationState() fast. |
Chris@0 | 21 $unique_keys = [ |
Chris@0 | 22 'content_entity_type_id', |
Chris@0 | 23 'content_entity_id', |
Chris@0 | 24 'content_entity_revision_id', |
Chris@0 | 25 'workflow', |
Chris@0 | 26 'langcode', |
Chris@0 | 27 ]; |
Chris@17 | 28 if ($data_table = $this->storage->getDataTable()) { |
Chris@17 | 29 $schema[$data_table]['unique keys'] += [ |
Chris@17 | 30 'content_moderation_state__lookup' => $unique_keys, |
Chris@17 | 31 ]; |
Chris@17 | 32 } |
Chris@17 | 33 if ($revision_data_table = $this->storage->getRevisionDataTable()) { |
Chris@17 | 34 $schema[$revision_data_table]['unique keys'] += [ |
Chris@17 | 35 'content_moderation_state__lookup' => $unique_keys, |
Chris@17 | 36 ]; |
Chris@17 | 37 } |
Chris@0 | 38 |
Chris@0 | 39 return $schema; |
Chris@0 | 40 } |
Chris@0 | 41 |
Chris@0 | 42 } |