f04466fbc31be9bab8373722401a732030687a3e
[yaffs-website] / web / core / modules / system / tests / modules / entity_test_update / src / EntityTestUpdateStorageSchema.php
1 <?php
2
3 namespace Drupal\entity_test_update;
4
5 use Drupal\Core\Entity\ContentEntityTypeInterface;
6 use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
7 use Drupal\Core\Field\FieldStorageDefinitionInterface;
8
9 /**
10  * Defines the entity_test_update storage_schema handler.
11  */
12 class EntityTestUpdateStorageSchema extends SqlContentEntityStorageSchema {
13
14   /**
15    * {@inheritdoc}
16    */
17   protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
18     $schema = parent::getEntitySchema($entity_type, $reset);
19
20     if ($entity_type->id() == 'entity_test_update') {
21       $schema[$this->storage->getBaseTable()]['indexes'] += \Drupal::state()->get('entity_test_update.additional_entity_indexes', []);
22     }
23     return $schema;
24   }
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
30     $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
31
32     if (\Drupal::state()->get('entity_test_update.additional_field_index.' . $table_name . '.' . $storage_definition->getName())) {
33       $this->addSharedTableFieldIndex($storage_definition, $schema);
34     }
35
36     return $schema;
37   }
38
39 }