function views_ui_view_preview_section_handler_links

Same name in other branches
  1. 9 core/modules/views_ui/views_ui.module \views_ui_view_preview_section_handler_links()
  2. 10 core/modules/views_ui/views_ui.module \views_ui_view_preview_section_handler_links()
  3. 11.x core/modules/views_ui/views_ui.module \views_ui_view_preview_section_handler_links()

Returns contextual links for each handler of a certain section.

@TODO Bring in relationships Refactor this function to use much stuff of views_ui_edit_form_get_bucket.

Parameters

$title: Add a bolded title of this section.

2 calls to views_ui_view_preview_section_handler_links()
template_preprocess_views_ui_view_preview_section in core/modules/views_ui/views_ui.theme.inc
Prepares variables for views UI view preview section templates.
views_ui_view_preview_section_rows_links in core/modules/views_ui/views_ui.module
Returns all contextual links for the main content part of the view.

File

core/modules/views_ui/views_ui.module, line 175

Code

function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type, $title = FALSE) {
    $display = $view->display_handler->display;
    $handlers = $view->display_handler
        ->getHandlers($type);
    $links = [];
    $types = ViewExecutable::getHandlerTypes();
    if ($title) {
        $links[$type . '-title'] = [
            'title' => $types[$type]['title'],
        ];
    }
    foreach ($handlers as $id => $handler) {
        $field_name = $handler->adminLabel(TRUE);
        $links[$type . '-edit-' . $id] = [
            'title' => t('Edit @section', [
                '@section' => $field_name,
            ]),
            'url' => Url::fromRoute('views_ui.form_handler', [
                'js' => 'nojs',
                'view' => $view->storage
                    ->id(),
                'display_id' => $display['id'],
                'type' => $type,
                'id' => $id,
            ]),
            'attributes' => [
                'class' => [
                    'views-ajax-link',
                ],
            ],
        ];
    }
    $links[$type . '-add'] = [
        'title' => t('Add new'),
        'url' => Url::fromRoute('views_ui.form_add_handler', [
            'js' => 'nojs',
            'view' => $view->storage
                ->id(),
            'display_id' => $display['id'],
            'type' => $type,
        ]),
        'attributes' => [
            'class' => [
                'views-ajax-link',
            ],
        ],
    ];
    return $links;
}

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