You are here

protected function MetatagViewsController::getViewsAndDisplaysLabels in Metatag 8

Gets label values for the views and their displays.

1 call to MetatagViewsController::getViewsAndDisplaysLabels()
MetatagViewsController::__construct in metatag_views/src/Controller/MetatagViewsController.php

File

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

Class

MetatagViewsController
Class MetatagViewsController.

Namespace

Drupal\metatag_views\Controller

Code

protected function getViewsAndDisplaysLabels() {

  /** @var \Drupal\views\ViewEntityInterface[] $views */
  $views = $this->viewStorage
    ->loadByProperties([
    'status' => 1,
  ]);
  $labels = [];
  foreach ($views as $view_id => $view) {
    $displays = $view
      ->get('display');
    $labels[$view_id]['#label'] = $view
      ->label();
    foreach (array_keys($displays) as $display_id) {
      $labels[$view_id][$display_id] = $displays[$display_id]['display_title'];
    }
  }
  $this->viewLabels = $labels;
}