You are here

public function EnvironmentIndicatorListBuilder::render in Environment Indicator 4.x

Same name and namespace in other branches
  1. 8.3 src/EnvironmentIndicatorListBuilder.php \Drupal\environment_indicator\EnvironmentIndicatorListBuilder::render()

Builds the entity listing as renderable array for table.html.twig.

@todo Add a link to add a new item to the #empty text.

Overrides EntityListBuilder::render

File

src/EnvironmentIndicatorListBuilder.php, line 54

Class

EnvironmentIndicatorListBuilder
Provides a listing of environments.

Namespace

Drupal\environment_indicator

Code

public function render() {
  $build['action_header']['#markup'] = '<h3>' . $this
    ->t('Available actions:') . '</h3>';
  $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. <a href=":link">Add environment</a>.', [
    ':link' => Url::fromRoute('entity.environment_indicator.add')
      ->toString(),
  ]);
  return $build;
}