function UserStorageSchema::getSharedTableFieldSchema

Same name in other branches
  1. 9 core/modules/user/src/UserStorageSchema.php \Drupal\user\UserStorageSchema::getSharedTableFieldSchema()
  2. 10 core/modules/user/src/UserStorageSchema.php \Drupal\user\UserStorageSchema::getSharedTableFieldSchema()
  3. 11.x core/modules/user/src/UserStorageSchema.php \Drupal\user\UserStorageSchema::getSharedTableFieldSchema()

Overrides SqlContentEntityStorageSchema::getSharedTableFieldSchema

File

core/modules/user/src/UserStorageSchema.php, line 42

Class

UserStorageSchema
Defines the user schema handler.

Namespace

Drupal\user

Code

protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
    $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
    $field_name = $storage_definition->getName();
    if ($table_name == 'users_field_data') {
        switch ($field_name) {
            case 'name':
                // Improves the performance of the user__name index defined
                // in getEntitySchema().
                $schema['fields'][$field_name]['not null'] = TRUE;
                // Make sure the field is no longer than 191 characters so we can
                // add a unique constraint in MySQL.
                $schema['fields'][$field_name]['length'] = UserInterface::USERNAME_MAX_LENGTH;
                break;
            case 'mail':
                $this->addSharedTableFieldIndex($storage_definition, $schema);
                break;
            case 'access':
            case 'created':
                $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
                break;
        }
    }
    return $schema;
}

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