You are here

function drush_xmlsitemap_index in XML sitemap 8

Same name and namespace in other branches
  1. 6.2 xmlsitemap.drush.inc \drush_xmlsitemap_index()
  2. 7.2 xmlsitemap.drush.inc \drush_xmlsitemap_index()

Process un-indexed XML sitemap links.

1 string reference to 'drush_xmlsitemap_index'
xmlsitemap_drush_command in ./xmlsitemap.drush.inc
Implements hook_drush_command().

File

./xmlsitemap.drush.inc, line 62
Drush integration functions for the xmlsitemap module.

Code

function drush_xmlsitemap_index() {
  $limit = (int) drush_get_option('limit', \Drupal::config('xmlsitemap.settings')
    ->get('batch_limit'));
  $count_before = \Drupal::database()
    ->select('xmlsitemap', 'x')
    ->countQuery()
    ->execute()
    ->fetchField();
  \Drupal::moduleHandler()
    ->invokeAll('xmlsitemap_index_links', [
    'limit' => $limit,
  ]);
  $count_after = \Drupal::database()
    ->select('xmlsitemap', 'x')
    ->countQuery()
    ->execute()
    ->fetchField();
  if ($count_after == $count_before) {
    drush_print(dt('No new XML sitemap links to index.'));
  }
  else {
    drush_print(dt('Indexed @count new XML sitemap links.', [
      '@count' => $count_after - $count_before,
    ]));
  }
}