function SqlContentEntityStorageSchema::addSharedTableFieldIndex

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::addSharedTableFieldIndex()
  2. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::addSharedTableFieldIndex()
  3. 11.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::addSharedTableFieldIndex()

Adds an index for the specified field to the given schema definition.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The storage definition of the field for which an index should be added.

array $schema: A reference to the schema array to be updated.

bool $not_null: (optional) Whether to also add a 'not null' constraint to the column being indexed. Doing so improves index performance. Defaults to FALSE, in case the field needs to support NULL values.

int $size: (optional) The index size. Defaults to no limit.

9 calls to SqlContentEntityStorageSchema::addSharedTableFieldIndex()
CommentStorageSchema::getSharedTableFieldSchema in core/modules/comment/src/CommentStorageSchema.php
Gets the schema for a single field definition.
EntityTestUpdateStorageSchema::getSharedTableFieldSchema in core/modules/system/tests/modules/entity_test_update/src/EntityTestUpdateStorageSchema.php
Gets the schema for a single field definition.
FeedStorageSchema::getSharedTableFieldSchema in core/modules/aggregator/src/FeedStorageSchema.php
Gets the schema for a single field definition.
FileStorageSchema::getSharedTableFieldSchema in core/modules/file/src/FileStorageSchema.php
Gets the schema for a single field definition.
ItemStorageSchema::getSharedTableFieldSchema in core/modules/aggregator/src/ItemStorageSchema.php
Gets the schema for a single field definition.

... See full list

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 2174

Class

SqlContentEntityStorageSchema
Defines a schema handler that supports revisionable, translatable entities.

Namespace

Drupal\Core\Entity\Sql

Code

protected function addSharedTableFieldIndex(FieldStorageDefinitionInterface $storage_definition, &$schema, $not_null = FALSE, $size = NULL) {
    $name = $storage_definition->getName();
    $real_key = $this->getFieldSchemaIdentifierName($storage_definition->getTargetEntityTypeId(), $name);
    $schema['indexes'][$real_key] = [
        $size ? [
            $name,
            $size,
        ] : $name,
    ];
    if ($not_null) {
        $schema['fields'][$name]['not null'] = TRUE;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.