You are here

protected function MetatagViewsController::buildViewDetails in Metatag 8

Builds the second "level" of the UI table with display fieldset and ops.

Parameters

string $view_id: The view display to use.

array $displays: The displays to process.

Return value

array Render array.

1 call to MetatagViewsController::buildViewDetails()
MetatagViewsController::listViews in metatag_views/src/Controller/MetatagViewsController.php
Generates the renderable array for views meta tags UI.

File

metatag_views/src/Controller/MetatagViewsController.php, line 123

Class

MetatagViewsController
Class MetatagViewsController.

Namespace

Drupal\metatag_views\Controller

Code

protected function buildViewDetails($view_id, array $displays) {
  $element = [
    '#type' => 'table',
    '#collapsible' => TRUE,
    '#header' => [
      $this
        ->t('Display'),
      $this
        ->t('Operations'),
    ],
  ];
  foreach ($displays as $display_id => $metatags) {
    $metatags = array_filter($metatags);
    $element[$display_id]['details'] = [
      '#type' => 'details',
      '#title' => $this->viewLabels[$view_id][$display_id],
    ];
    $params = [
      'view_id' => $view_id,
      'display_id' => $display_id,
    ];

    // Generate the operations.
    $element[$display_id]['ops'] = [
      '#type' => 'operations',
      '#links' => [
        'edit' => [
          'title' => $this
            ->t('Edit'),
          'url' => Url::fromRoute('metatag_views.metatags.edit', $params),
        ],
        'translate' => [
          'title' => $this
            ->t('Translate'),
          'url' => Url::fromRoute('metatag_views.metatags.translate_overview', $params),
        ],
        'revert' => [
          'title' => $this
            ->t('Revert'),
          'url' => Url::fromRoute('metatag_views.metatags.revert', $params),
        ],
      ],
    ];

    // Build the rows for each of the metatag types.
    $element[$display_id]['details']['table'] = $this
      ->buildDisplayDetailsTable($metatags);
  }
  return $element;
}