You are here

protected function DevelController::getBaseRow in Search API Solr 8.2

Same name and namespace in other branches
  1. 8.3 modules/search_api_solr_devel/src/Controller/DevelController.php \Drupal\search_api_solr_devel\Controller\DevelController::getBaseRow()
  2. 4.x modules/search_api_solr_devel/src/Controller/DevelController.php \Drupal\search_api_solr_devel\Controller\DevelController::getBaseRow()

Return a base row for the summary table, which will be modified later on.

Parameters

\Drupal\search_api\ServerInterface $server:

\Drupal\search_api\IndexInterface $index:

string $datasource_id:

Entity $entity:

string $langcode:

string $item_id:

Return value

string[]

1 call to DevelController::getBaseRow()
DevelController::entitySolr in search_api_solr_devel/src/Controller/DevelController.php
Prints the document structure to be indexed by Solr.

File

search_api_solr_devel/src/Controller/DevelController.php, line 325

Class

DevelController
Returns responses for devel module routes.

Namespace

Drupal\search_api_solr_devel\Controller

Code

protected function getBaseRow($server, $index, $datasource_id, $entity, $langcode, $item_id) {

  // Build table row.
  $base_row = [
    'num' => 0,
    'server' => $this
      ->t('<a href=":url">@id</a>', [
      '@id' => $server
        ->id(),
      ':url' => Url::fromRoute('entity.search_api_server.canonical', [
        'search_api_server' => $server
          ->id(),
      ])
        ->toString(),
    ]),
    'index' => $this
      ->t('<a href=":index_url">@index_id</a><br />(%read_write_mode mode)', [
      '@index_id' => $index
        ->id(),
      ':index_url' => Url::fromRoute('entity.search_api_index.canonical', [
        'search_api_index' => $index
          ->id(),
      ])
        ->toString(),
      '%read_write_mode' => $index
        ->isReadOnly() ? $this
        ->t('read-only') : $this
        ->t('read-write'),
    ]),
    'id' => $datasource_id . '/' . $entity
      ->id(),
    'langcode' => $langcode,
    'tracked' => '',
    'changed' => '-',
    'status' => '-',
    'object_size' => '-',
    'solr_id' => '-',
    'solr_exists' => '',
    'solr_changed' => '-',
    'solr_size' => '-',
  ];

  // Fetch tracker information.
  $tracker = $index
    ->getTrackerInstance();
  $select = $tracker
    ->getDatabaseConnection()
    ->select('search_api_item', 'sai');
  $select
    ->condition('index_id', $index
    ->id());
  $select
    ->condition('datasource', $datasource_id);
  $select
    ->condition('item_id', $item_id);
  $select
    ->fields('sai', [
    'item_id',
    'status',
    'changed',
  ]);
  $tracker_data = $select
    ->execute()
    ->fetch();

  // Add tracker information to row.
  if ($tracker_data) {
    $base_row['tracked'] = $this
      ->t('yes');
    $base_row['changed'] = $this
      ->showTimeAndTimeAgo($tracker_data->changed);
    $base_row['status'] = $tracker_data->status ? $this
      ->t('no') : $this
      ->t('yes');
  }
  else {
    $base_row['tracked'] = $this
      ->t('no');
  }
  return $base_row;
}