You are here

public function SimpleSitemapViews::getIndexIdByPosition in Simple XML sitemap (Views integration) 8

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

src/SimpleSitemapViews.php, line 237
Contains simple_sitemap_views service.

Class

SimpleSitemapViews
Class to manage sitemap data for views.

Namespace

Drupal\simple_sitemap_views

Code

public function getIndexIdByPosition($position, ConditionInterface $condition = NULL) {
  $query = $this->database
    ->select('simple_sitemap_views', 'ssv');
  $query
    ->addField('ssv', 'id');

  // Add conditions if necessary.
  if (!empty($condition)) {
    $query
      ->condition($condition);
  }
  $query
    ->orderBy('id', 'ASC');
  $query
    ->range($position - 1, 1);
  return $query
    ->execute()
    ->fetchField();
}