Exemplo n.º 1
0
  /**
   * {@inheritdoc}
   */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    // @todo This will, via Index::onDependencyRemoval(), remove all indexes
    // from this server, triggering the server's removeIndex() method. This is,
    // at best, wasted performance and could at worst lead to a bug if
    // removeIndex() saves the server. We should try what happens when this is
    // the case, whether there really is a bug, and try to fix it somehow (maybe
    // clever detection of this case in removeIndex() or Index::postSave().
    parent::preDelete($storage, $entities);

    // Iterate through the servers, executing the backends' preDelete() methods
    // and removing all their pending server tasks.
    foreach ($entities as $server) {
      /** @var \Drupal\search_api\ServerInterface $server */
      if ($server->hasValidBackend()) {
        $server->getBackend()->preDelete();
      }
      Utility::getServerTaskManager()->delete(NULL, $server);
    }
  }