You are here

public function SearchPageListBuilder::buildRow in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/search/src/SearchPageListBuilder.php \Drupal\search\SearchPageListBuilder::buildRow()

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.

Return value

array A render array structure of fields for this entity.

Overrides DraggableListBuilder::buildRow

See also

\Drupal\Core\Entity\EntityListBuilder::render()

File

core/modules/search/src/SearchPageListBuilder.php, line 140

Class

SearchPageListBuilder
Defines a class to build a listing of search page entities.

Namespace

Drupal\search

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\search\SearchPageInterface $entity */
  $row['label'] = $entity
    ->label();
  $row['url']['#markup'] = 'search/' . $entity
    ->getPath();

  // If the search page is active, link to it.
  if ($entity
    ->status()) {
    $row['url'] = [
      '#type' => 'link',
      '#title' => $row['url'],
      '#url' => Url::fromRoute('search.view_' . $entity
        ->id()),
    ];
  }
  $definition = $entity
    ->getPlugin()
    ->getPluginDefinition();
  $row['plugin']['#markup'] = $definition['title'];
  if ($entity
    ->isDefaultSearch()) {
    $status = $this
      ->t('Default');
  }
  elseif ($entity
    ->status()) {
    $status = $this
      ->t('Enabled');
  }
  else {
    $status = $this
      ->t('Disabled');
  }
  $row['status']['#markup'] = $status;
  if ($entity
    ->isIndexable()) {
    $status = $entity
      ->getPlugin()
      ->indexStatus();
    $row['progress']['#markup'] = $this
      ->t('%num_indexed of %num_total indexed', [
      '%num_indexed' => $status['total'] - $status['remaining'],
      '%num_total' => $status['total'],
    ]);
  }
  else {
    $row['progress']['#markup'] = $this
      ->t('Does not use index');
  }
  return $row + parent::buildRow($entity);
}