SearchPageListBuilder::buildRow

public SearchPageListBuilder::buildRow(EntityInterface $entity)

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 117

Class

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

Namespace

Drupal\search

Code

public function buildRow(EntityInterface $entity) {
  /** @var $entity \Drupal\search\SearchPageInterface */
  $row['label'] = $entity->label();
  $row['url']['#markup'] = 'search/' . $entity->getPath();
  // If the search page is active, link to it.
  if ($entity->status()) {
    $row['url'] = array(
      '#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', array(
      '%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);
}
doc_Drupal
2016-10-29 09:40:41
Comments
Leave a Comment

Please login to continue.