You are here

protected function DevelController::getBaseRow in Search API Solr 8.3

Same name and namespace in other branches
  1. 8.2 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: The Search API server entity.

\Drupal\search_api\IndexInterface $index: The Search API index entity.

string $datasource_id: The ID of the datasource.

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to return the base row.

string $langcode: The language code.

string $item_id: The internal item ID of the entity.

Return value

string[] An associative array of strings for the base row.

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

File

modules/search_api_solr_devel/src/Controller/DevelController.php, line 351

Class

DevelController
Returns responses for devel module routes.

Namespace

Drupal\search_api_solr_devel\Controller

Code

protected function getBaseRow(ServerInterface $server, IndexInterface $index, $datasource_id, EntityInterface $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;
}