W3cubDocs

/Drupal 8

function views_ui_view_preview_section_handler_links

views_ui_view_preview_section_handler_links(ViewExecutable $view, $type, $title = FALSE)

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.

File

core/modules/views_ui/views_ui.module, line 154
Provide structure for the administrative interface to Views.

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 = array();

  $types = ViewExecutable::getHandlerTypes();
  if ($title) {
    $links[$type . '-title'] = array(
      'title' => $types[$type]['title'],
    );
  }

  foreach ($handlers as $id => $handler) {
    $field_name = $handler->adminLabel(TRUE);
    $links[$type . '-edit-' . $id] = array(
      'title' => t('Edit @section', array('@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' => array('class' => array('views-ajax-link')),
    );
  }
  $links[$type . '-add'] = array(
    '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' => array('class' => array('views-ajax-link')),
  );

  return $links;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!views_ui!views_ui.module/function/views_ui_view_preview_section_handler_links/8.1.x