You are here

public function SimpleSitemapViews::getIndexIdByPosition in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 modules/simple_sitemap_views/src/SimpleSitemapViews.php \Drupal\simple_sitemap_views\SimpleSitemapViews::getIndexIdByPosition()

Returns the ID of the record in the index for the specified position.

Parameters

int $position: Position of the record.

\Drupal\Core\Database\Query\ConditionInterface|null $condition: The query conditions.

Return value

int|bool The ID of the record, or FALSE if there is no specified position.

File

modules/simple_sitemap_views/src/SimpleSitemapViews.php, line 410

Class

SimpleSitemapViews
Class to manage sitemap data for views.

Namespace

Drupal\simple_sitemap_views

Code

public function getIndexIdByPosition(int $position, ?ConditionInterface $condition = NULL) {
  $query = $this->database
    ->select('simple_sitemap_views', 'ssv');
  $query
    ->addField('ssv', 'id');
  if ($condition !== NULL) {
    $query
      ->condition($condition);
  }
  $query
    ->orderBy('id');
  $query
    ->range($position - 1, 1);
  return $query
    ->execute()
    ->fetchField();
}