You are here

public function BackgroundImageManager::getViewsPages in Background Image 8

Same name and namespace in other branches
  1. 2.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::getViewsPages()
  2. 2.0.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::getViewsPages()

Return value

array

Overrides BackgroundImageManagerInterface::getViewsPages

1 call to BackgroundImageManager::getViewsPages()
BackgroundImageManager::validView in src/BackgroundImageManager.php
Checks whether a view can use background images.

File

src/BackgroundImageManager.php, line 659

Class

BackgroundImageManager

Namespace

Drupal\background_image

Code

public function getViewsPages() {
  static $views;
  if (!isset($views)) {
    $views = [];
    if (!$this->moduleHandler
      ->moduleExists('views')) {
      return $views;
    }
    foreach (Views::getEnabledViews() as $view_id => $view) {
      $displays = $view
        ->get('display');
      foreach ($displays as $display_id => $display) {
        if ($display['display_plugin'] === 'page') {
          $id = "{$view_id}:{$display_id}";
          if (isset($display['display_options']['menu']['title'])) {
            $views[$id] = $display['display_options']['menu']['title'] . " ({$id})";
          }
          else {
            $label = $view
              ->label();
            if (isset($display['display_title']) && $display['display_title'] !== 'Page') {
              $label .= ' - ' . $display['display_title'];
            }
            $views[$id] = $label . " ({$id})";
          }
        }
      }
    }
    ksort($views, SORT_NATURAL);
  }
  return $views;
}