You are here

public function FlowListBuilder::render in CMS Content Sync 8

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

Class

FlowListBuilder
Provides a listing of Flow.

Namespace

Drupal\cms_content_sync\Controller

Code

public function render() {
  $build = parent::render();
  $status_overwritten = false;
  $version_mismatch = false;
  $rows = $build['table']['#rows'];
  if (!empty($rows)) {
    foreach ($rows as $row) {
      if (strpos($row['status']
        ->__toString(), 'Overwritten')) {
        $status_overwritten = true;
      }
      if (strpos($row['status']
        ->__toString(), 'Version mismatch')) {
        $version_mismatch = true;
      }
    }
    if ($status_overwritten) {
      $build['explanation_overwritten'] = [
        '#markup' => '<i>' . $this
          ->t('Overwritten: The status of this flow has been overwritten in a settings file.') . '</i><br>',
      ];
    }
    if ($version_mismatch) {
      $build['explanation_version_mismatch'] = [
        '#markup' => '<i>' . $this
          ->t('Version mismatch: The flow contains mismatching bundle versions and needs to be re-saved and exported.') . '</i>',
      ];
    }
    $build['hints'] = [
      '#markup' => '<h3>' . $this
        ->t('Hints') . '</h3>' . $this
        ->t('You can enable / disable Flows using your settings.php file:'),
    ];
    $overwrite_status = '<li>' . $this
      ->t('Status: <i>@overwrite_status</i>', [
      '@overwrite_status' => '$config["cms_content_sync.flow.<flow_machine_name>"]["status"] = FALSE;',
    ]) . '</li>';
    $build['hints_examples'] = [
      '#markup' => '<ul>' . $overwrite_status . '</ul>',
    ];
  }
  return $build;
}