You are here

public function SimpleSitemapViewsController::content in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x modules/simple_sitemap_views/src/Controller/SimpleSitemapViewsController.php \Drupal\simple_sitemap_views\Controller\SimpleSitemapViewsController::content()

Builds a listing of indexed views displays.

Return value

array A render array.

1 string reference to 'SimpleSitemapViewsController::content'
simple_sitemap_views.routing.yml in modules/simple_sitemap_views/simple_sitemap_views.routing.yml
modules/simple_sitemap_views/simple_sitemap_views.routing.yml

File

modules/simple_sitemap_views/src/Controller/SimpleSitemapViewsController.php, line 48

Class

SimpleSitemapViewsController
Controller for Simple XML Sitemap Views admin page.

Namespace

Drupal\simple_sitemap_views\Controller

Code

public function content() {
  $table = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('View'),
      $this
        ->t('Display'),
      $this
        ->t('Variants'),
      $this
        ->t('Operations'),
    ],
    '#empty' => $this
      ->t('No view displays are set to be indexed yet. <a href="@url">Edit a view.</a>', [
      '@url' => $GLOBALS['base_url'] . '/admin/structure/views',
    ]),
  ];
  foreach ($this->sitemapViews
    ->getIndexableViews() as $index => $view) {
    $table[$index]['view'] = [
      '#markup' => $view->storage
        ->label(),
    ];
    $table[$index]['display'] = [
      '#markup' => $view->display_handler->display['display_title'],
    ];
    $variants = $this->sitemapViews
      ->getIndexableVariants($view);
    $variants = implode(', ', array_keys($variants));
    $table[$index]['variants'] = [
      '#markup' => $variants,
    ];

    // Link to view display edit form.
    $display_edit_url = Url::fromRoute('entity.view.edit_display_form', [
      'view' => $view
        ->id(),
      'display_id' => $view->current_display,
    ]);
    $table[$index]['operations'] = [
      '#type' => 'operations',
      '#links' => [
        'display_edit' => [
          'title' => $this
            ->t('Edit'),
          'url' => $display_edit_url,
        ],
      ],
    ];
  }

  // Show information about indexed displays.
  $build['simple_sitemap_views'] = [
    '#prefix' => FormHelper::getDonationText(),
    '#title' => $this
      ->t('Indexed view displays'),
    '#type' => 'fieldset',
    'table' => $table,
  ];
  return $build;
}