views_ui_build_form_url

views_ui_build_form_url(FormStateInterface $form_state)

Create the menu path for one of our standard AJAX forms based upon known information about the form.

Return value

\Drupal\Core\Url The URL object pointing to the form URL.

File

core/modules/views_ui/admin.inc, line 277
Provides the Views' administrative interface.

Code

function views_ui_build_form_url(FormStateInterface $form_state) {
  $ajax = !$form_state->get('ajax') ? 'nojs' : 'ajax';
  $name = $form_state->get('view')->id();
  $form_key = $form_state->get('form_key');
  $display_id = $form_state->get('display_id');

  $form_key = str_replace('-', '_', $form_key);
  $route_name = "views_ui.form_{$form_key}";
  $route_parameters = [
    'js' => $ajax,
    'view' => $name,
    'display_id' => $display_id
  ];
  $url = Url::fromRoute($route_name, $route_parameters);
  if ($type = $form_state->get('type')) {
    $url->setRouteParameter('type', $type);
  }
  if ($id = $form_state->get('id')) {
    $url->setRouteParameter('id', $id);
  }
  return $url;
}
doc_Drupal
2016-10-29 09:55:41
Comments
Leave a Comment

Please login to continue.