class ViewsUiThemeHooks

Hook implementations for views_ui.

Hierarchy

Expanded class hierarchy of ViewsUiThemeHooks

File

core/modules/views_ui/src/Hook/ViewsUiThemeHooks.php, line 11

Namespace

Drupal\views_ui\Hook
View source
class ViewsUiThemeHooks {
  
  /**
   * Implements hook_preprocess_HOOK() for views templates.
   */
  public function preprocessViewsView(&$variables) : void {
    $view = $variables['view'];
    // Render title for the admin preview.
    if (!empty($view->live_preview)) {
      $variables['title'] = [
        '#markup' => $view->getTitle(),
        '#allowed_tags' => Xss::getHtmlTagList(),
      ];
    }
    if (!empty($view->live_preview) && \Drupal::moduleHandler()->moduleExists('contextual')) {
      $view->setShowAdminLinks(FALSE);
      foreach ([
        'title',
        'header',
        'exposed',
        'rows',
        'pager',
        'more',
        'footer',
        'empty',
        'attachment_after',
        'attachment_before',
      ] as $section) {
        if (!empty($variables[$section])) {
          $variables[$section] = [
            '#theme' => 'views_ui_view_preview_section',
            '#view' => $view,
            '#section' => $section,
            '#content' => $variables[$section],
            '#theme_wrappers' => [
              'views_ui_container',
            ],
            '#attributes' => [
              'class' => [
                'contextual-region',
              ],
            ],
          ];
        }
      }
    }
  }
  
  /**
   * Implements hook_theme_suggestions_HOOK().
   */
  public function themeSuggestionsViewsUiViewPreviewSection(array $variables) : array {
    return [
      'views_ui_view_preview_section__' . $variables['section'],
    ];
  }

}

Members

Title Sort descending Modifiers Object type Summary
ViewsUiThemeHooks::preprocessViewsView public function Implements hook_preprocess_HOOK() for views templates.
ViewsUiThemeHooks::themeSuggestionsViewsUiViewPreviewSection public function Implements hook_theme_suggestions_HOOK().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.