You are here

public function SimpleSitemapViews::getArgumentsFromIndex in Simple XML sitemap 8.3

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

Get arguments from index.

Parameters

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

int|null $limit: The number of records to return from the result set. If NULL, returns all records.

bool $convert: Defaults to FALSE. If TRUE, the argument string will be converted to an array.

Return value

array An array with information about the indexed arguments.

File

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

Class

SimpleSitemapViews
Class to manage sitemap data for views.

Namespace

Drupal\simple_sitemap_views

Code

public function getArgumentsFromIndex(ConditionInterface $condition = NULL, $limit = NULL, $convert = FALSE) {
  $query = $this->database
    ->select('simple_sitemap_views', 'ssv');
  $query
    ->addField('ssv', 'id');
  $query
    ->addField('ssv', 'view_id');
  $query
    ->addField('ssv', 'display_id');
  $query
    ->addField('ssv', 'arguments_values', 'arguments');
  if (!empty($condition)) {
    $query
      ->condition($condition);
  }
  if (!empty($limit)) {
    $query
      ->range(0, $limit);
  }
  $rows = $query
    ->execute()
    ->fetchAll();
  $arguments = [];
  foreach ($rows as $row) {
    $arguments[$row->id] = [
      'view_id' => $row->view_id,
      'display_id' => $row->display_id,
      'arguments' => $convert ? $this
        ->convertArgumentsStringToArray($row->arguments) : $row->arguments,
    ];
  }
  return $arguments;
}