diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index ca8bd430ba..860453631a 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -15,6 +15,7 @@ use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; /** * Form controller for the Views edit form. @@ -413,27 +414,26 @@ public function getDisplayDetails($view, $display) { // Add a link to view the page unless the view is disabled or has no // path. elseif ($view->status() && $view->getExecutable()->displayHandlers->get($display['id'])->hasPath()) { - // Wrap this in a try/catch as tryng to generate links to some - // routes may throw a NotAcceptableHttpException if they do not - // respond to HTML, such as RESTExports. - try { - // @todo Views should expect and store a leading /. See: - // https://www.drupal.org/node/2423913 - $path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path)); - } - catch (NotAcceptableHttpException $e) { - $path = '/' . $path; - } + $path = $view->getExecutable()->displayHandlers->get($display['id'])->getPath(); if ($path && (strpos($path, '%') === FALSE)) { - if (!parse_url($path, PHP_URL_SCHEME)) { - // @todo Views should expect and store a leading /. See: - // https://www.drupal.org/node/2423913 - $url = Url::fromUserInput('/' . ltrim($path, '/')); + // Wrap this in a try/catch as trying to generate links to some + // routes may throw a NotAcceptableHttpException if they do not + // respond to HTML, such as RESTExports. + try { + if (!parse_url($path, PHP_URL_SCHEME)) { + // @todo Views should expect and store a leading /. See: + // https://www.drupal.org/node/2423913 + $url = Url::fromUserInput('/' . ltrim($path, '/')); + } + else { + $url = Url::fromUri("base:$path"); + } } - else { - $url = Url::fromUri("base:$path"); + catch (NotAcceptableHttpException $e) { + $url = '/' . $path; } + $build['top']['actions']['path'] = array( '#type' => 'link', '#title' => $this->t('View @display_title', ['@display_title' => $display_title]),