public function IndexListBuilder::buildRow in Search API 8
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 EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
1 call to IndexListBuilder::buildRow()
- IndexListBuilder::render in src/
IndexListBuilder.php - Builds the entity listing as renderable array for table.html.twig.
File
- src/
IndexListBuilder.php, line 167
Class
- IndexListBuilder
- Builds a listing of search index entities.
Namespace
Drupal\search_apiCode
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
$row = parent::buildRow($entity);
$status = $entity
->status();
$row = [
'data' => [
'type' => [
'data' => $entity instanceof ServerInterface ? $this
->t('Server') : $this
->t('Index'),
'class' => [
'search-api-type',
],
],
'title' => [
'data' => [
'#type' => 'link',
'#title' => $entity
->label(),
] + $entity
->toUrl('canonical')
->toRenderArray(),
'class' => [
'search-api-title',
],
],
'status' => [
'data' => $status ? $this
->t('Enabled') : $this
->t('Disabled'),
'class' => [
'search-api-status',
],
],
'operations' => $row['operations'],
],
'title' => $this
->t('ID: @name', [
'@name' => $entity
->id(),
]),
'class' => [
Html::cleanCssIdentifier($entity
->getEntityTypeId() . '-' . $entity
->id()),
$status ? 'search-api-list-enabled' : 'search-api-list-disabled',
$entity instanceof ServerInterface ? 'search-api-list-server' : 'search-api-list-index',
],
];
$description = $entity
->get('description');
if ($description) {
$row['data']['title']['data']['#suffix'] = '<div class="description">' . $description . '</div>';
}
if ($status && $entity instanceof ServerInterface && !$entity
->isAvailable()) {
$row['data']['status']['data'] = $this
->t('Unavailable');
$row['class'][] = 'color-error';
}
return $row;
}