You are here

protected function SearchApiDbService::removeFieldStorage in Search API Database Search 7

Drops a field's table or column for storage.

Parameters

string $name: The field name.

array $field: Server-internal information about the field.

1 call to SearchApiDbService::removeFieldStorage()
SearchApiDbService::fieldsUpdated in ./service.inc
Overrides SearchApiAbstractService::fieldsUpdated().

File

./service.inc, line 762
Contains SearchApiDbService.

Class

SearchApiDbService
Indexes and searches items using the database.

Code

protected function removeFieldStorage($name, $field) {

  // This might, in some instances, be called when the necessary table hasn't
  // even been created yet.
  if (!$this->connection
    ->schema()
    ->tableExists($field['table'])) {
    return;
  }
  if (search_api_is_text_type($field['type'])) {
    $this->connection
      ->delete($field['table'])
      ->condition('field_name', self::getTextFieldName($name))
      ->execute();
  }
  elseif ($this
    ->canDenormalize($field) && isset($field['column'])) {
    $this->connection
      ->schema()
      ->dropField($field['table'], $field['column']);
  }
  elseif ($this->connection
    ->schema()
    ->tableExists($field['table'])) {
    $this->connection
      ->schema()
      ->dropTable($field['table']);
  }
}