You are here

public function PoolListBuilder::render in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Controller/PoolListBuilder.php \Drupal\cms_content_sync\Controller\PoolListBuilder::render()
  2. 2.0.x src/Controller/PoolListBuilder.php \Drupal\cms_content_sync\Controller\PoolListBuilder::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/Controller/PoolListBuilder.php, line 86

Class

PoolListBuilder
Provides a listing of Pool.

Namespace

Drupal\cms_content_sync\Controller

Code

public function render() {
  $build = parent::render();
  $overwritten = false;
  $rows = $build['table']['#rows'];
  if (!empty($rows)) {
    foreach ($rows as $row) {
      if (strpos($row['backend_url']
        ->__toString(), 'Overwritten')) {
        $overwritten = true;
      }
    }
    if ($overwritten) {
      $build['explanation_overwritten'] = [
        '#markup' => '<i>' . $this
          ->t('Overwritten: This configuration has been overwritten within your settings.php file.') . '</i><br>',
      ];
    }
    $build['hints'] = [
      '#markup' => '<h3>' . $this
        ->t('Hints') . '</h3>' . $this
        ->t('You can overwrite parts of your pool configuration using your settings.php file:'),
    ];
    $overwrite_sync_core_url_example = '<li>' . $this
      ->t('Sync Core URL: <i>@overwrite_sync_core_url</i>', [
      '@overwrite_sync_core_url' => '$settings["cms_content_sync"]["pools"][<pool_machine_name>]["backend_url"] = "http://example.com";',
    ]) . '</li>';
    $build['hints_examples'] = [
      '#markup' => '<ul>' . $overwrite_sync_core_url_example . '</ul>',
    ];
  }
  return $build;
}