function SearchPageListBuilder::buildRow

Same name in other branches
  1. 8.9.x core/modules/search/src/SearchPageListBuilder.php \Drupal\search\SearchPageListBuilder::buildRow()
  2. 10 core/modules/search/src/SearchPageListBuilder.php \Drupal\search\SearchPageListBuilder::buildRow()
  3. 11.x core/modules/search/src/SearchPageListBuilder.php \Drupal\search\SearchPageListBuilder::buildRow()

Overrides DraggableListBuilder::buildRow

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.