You are here

function skinr_ui_page_display_pre_render in Skinr 8.2

#pre_render callback to set contextual links for views using a Page display.

File

skinr_ui/skinr_ui.module, line 215
Handles Skinr UI functionality allowing users to apply skins to their site.

Code

function skinr_ui_page_display_pre_render(array $element) {

  // Add contextual links for views.
  // If the main content of this page contains a view, attach its contextual
  // links to the overall page array. This allows them to be rendered directly
  // next to the page title.
  if ($view = views_get_page_view()) {
    if (\Drupal::moduleHandler()
      ->moduleExists('contextual') && $view
      ->getShowAdminLinks()) {
      $element['#contextual_links']['skinr'] = array(
        'route_parameters' => array(
          'element_type' => 'view',
          'element' => $view
            ->id() . '__' . $view->current_display,
          'theme' => \Drupal::theme()
            ->getActiveTheme()
            ->getName(),
        ),
      );
    }
  }
  return $element;
}