You are here

public function BackendPluginBase::preDelete in Search API 8

Notifies the backend that the server is about to be deleted.

This should execute any necessary cleanup operations.

Note that you shouldn't call the server's save() method, or any methods that might do that, from inside of this method as the server isn't present in the database anymore at this point.

Overrides BackendInterface::preDelete

1 method overrides BackendPluginBase::preDelete()
Database::preDelete in modules/search_api_db/src/Plugin/search_api/backend/Database.php
Notifies the backend that the server is about to be deleted.

File

src/Backend/BackendPluginBase.php, line 222

Class

BackendPluginBase
Defines a base class for backend plugins.

Namespace

Drupal\search_api\Backend

Code

public function preDelete() {
  try {
    $this
      ->getServer()
      ->deleteAllItems();
  } catch (SearchApiException $e) {
    $vars = [
      '%server' => $this
        ->getServer()
        ->label(),
    ];
    $this
      ->logException($e, '%type while deleting items from server %server: @message in %function (line %line of %file).', $vars);
    $this
      ->getMessenger()
      ->addError($this
      ->t('Deleting some of the items on the server failed. Check the logs for details. The server was still removed.'));
  }
}