X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fenvironment_indicator%2Fsrc%2FEnvironmentIndicatorListBuilder.php;fp=web%2Fmodules%2Fcontrib%2Fenvironment_indicator%2Fsrc%2FEnvironmentIndicatorListBuilder.php;h=0e193a823802df029859ee7fafab011f173495bb;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorListBuilder.php b/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorListBuilder.php new file mode 100644 index 000000000..0e193a823 --- /dev/null +++ b/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorListBuilder.php @@ -0,0 +1,66 @@ +t('Environment name'); + $row['url'] = $this->t('Environment url'); + $row += parent::buildHeader(); + return $row; + } + + /** + * {@inheritdoc} + */ + public function buildRow(EntityInterface $entity) { + /* @var \Drupal\environment_indicator\Entity\EnvironmentIndicator $entity */ + $row = [ + 'style' => 'color: ' . $entity->getFgColor() . '; background-color: ' . $entity->getBgColor() . ';', + ]; + + $row['data']['name'] = [ + 'data' => $entity->label(), + ]; + $row['data']['url'] = [ + 'data' => $entity->getUrl(), + ]; + + $row['data'] += parent::buildRow($entity); + return $row; + } + + /** + * {@inheritdoc} + */ + public function render() { + $build['action_header']['#markup'] = '

' . t('Available actions:') . '

'; + $entities = $this->load(); + // If there are not multiple vocabularies, disable dragging by unsetting the + // weight key. + if (count($entities) <= 1) { + unset($this->weightKey); + } + $build = parent::render(); + $build['table']['#empty'] = $this->t('No environment switchers available. Add environment.', [':link' => \Drupal::url('entity.environment_indicator.add')]); + return $build; + } + +}