You are here

public function XmlSitemapGenerator::rebuildBatchClear in XML sitemap 8

Same name and namespace in other branches
  1. 2.x src/XmlSitemapGenerator.php \Drupal\xmlsitemap\XmlSitemapGenerator::rebuildBatchClear()

Batch callback; clear sitemap links for entites.

Parameters

array $entity_type_ids: Entity types to rebuild.

bool $save_custom: Save custom data.

array|\ArrayAccess $context: Context to be rebuilt.

Overrides XmlSitemapGeneratorInterface::rebuildBatchClear

File

src/XmlSitemapGenerator.php, line 492

Class

XmlSitemapGenerator
XmlSitemap generator service class.

Namespace

Drupal\xmlsitemap

Code

public function rebuildBatchClear(array $entity_type_ids, $save_custom, &$context) {
  if (!empty($entity_type_ids)) {

    // Let other modules respond to the rebuild clearing.
    $this->moduleHandler
      ->invokeAll('xmlsitemap_rebuild_clear', [
      $entity_type_ids,
      $save_custom,
    ]);
    $query = $this->connection
      ->delete('xmlsitemap');
    $query
      ->condition('type', $entity_type_ids, 'IN');

    // If we want to save the custom data, make sure to exclude any links
    // that are not using default inclusion or priority.
    if ($save_custom) {
      $query
        ->condition('status_override', 0);
      $query
        ->condition('priority_override', 0);
    }
    $query
      ->execute();
  }
  $context['message'] = $this
    ->t('Links cleared');
}