3 namespace Drupal\environment_indicator;
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
9 * Provides a listing of environments.
11 class EnvironmentIndicatorListBuilder extends ConfigEntityListBuilder {
16 public function getFormID() {
17 return 'environment_indicator_overview_environments';
23 public function buildHeader() {
24 $row['name'] = $this->t('Environment name');
25 $row['url'] = $this->t('Environment url');
26 $row += parent::buildHeader();
33 public function buildRow(EntityInterface $entity) {
34 /* @var \Drupal\environment_indicator\Entity\EnvironmentIndicator $entity */
36 'style' => 'color: ' . $entity->getFgColor() . '; background-color: ' . $entity->getBgColor() . ';',
39 $row['data']['name'] = [
40 'data' => $entity->label(),
42 $row['data']['url'] = [
43 'data' => $entity->getUrl(),
46 $row['data'] += parent::buildRow($entity);
53 public function render() {
54 $build['action_header']['#markup'] = '<h3>' . t('Available actions:') . '</h3>';
55 $entities = $this->load();
56 // If there are not multiple vocabularies, disable dragging by unsetting the
58 if (count($entities) <= 1) {
59 unset($this->weightKey);
61 $build = parent::render();
62 $build['table']['#empty'] = $this->t('No environment switchers available. <a href=":link">Add environment</a>.', [':link' => \Drupal::url('entity.environment_indicator.add')]);