SavedSearchTypeListBuilder.php in Search API Saved Searches 8
File
src/SavedSearchTypeListBuilder.php
View source
<?php
namespace Drupal\search_api_saved_searches;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
class SavedSearchTypeListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
return [
'label' => $this
->t('Name'),
'description' => $this
->t('Description'),
'status' => $this
->t('Status'),
] + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$status = $entity
->status();
$status_label = $status ? $this
->t('Enabled') : $this
->t('Disabled');
$status_icon = [
'#theme' => 'image',
'#uri' => $status ? 'core/misc/icons/73b355/check.svg' : 'core/misc/icons/e32700/error.svg',
'#width' => 18,
'#height' => 18,
'#alt' => $status_label,
'#title' => $status_label,
];
$row = [
'data' => [
'label' => $entity
->label(),
'description' => [
'data' => [
'#markup' => $entity
->getDescription(),
],
],
'status' => [
'data' => $status_icon,
],
],
'title' => $this
->t('ID: @name', [
'@name' => $entity
->id(),
]),
'class' => [
$status ? 'search-api-list-enabled' : 'search-api-list-disabled',
],
];
$row['data'] += parent::buildRow($entity);
return $row;
}
public function render() {
$build = parent::render();
$build['#attached']['library'][] = 'search_api/drupal.search_api.admin_css';
return $build;
}
}