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