protected function SqlContentEntityStorageSchema::addSharedTableFieldIndex

protected SqlContentEntityStorageSchema::addSharedTableFieldIndex(FieldStorageDefinitionInterface $storage_definition, &$schema, $not_null = FALSE, $size = NULL)

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.

File

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

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] = array($size ? array($name, $size) : $name);
  if ($not_null) {
    $schema['fields'][$name]['not null'] = TRUE;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorageSchema.php/function/SqlContentEntityStorageSchema::addSharedTableFieldIndex/8.1.x