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;
}
doc_Drupal
2016-10-29 09:55:44
Comments
Leave a Comment

Please login to continue.