Mercurial > hg > isophonics-drupal-site
comparison core/modules/views_ui/src/ViewEditForm.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 7a779792577d |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
9 use Drupal\Core\Ajax\ReplaceCommand; | 9 use Drupal\Core\Ajax\ReplaceCommand; |
10 use Drupal\Core\Datetime\DateFormatterInterface; | 10 use Drupal\Core\Datetime\DateFormatterInterface; |
11 use Drupal\Core\Form\FormStateInterface; | 11 use Drupal\Core\Form\FormStateInterface; |
12 use Drupal\Core\Render\ElementInfoManagerInterface; | 12 use Drupal\Core\Render\ElementInfoManagerInterface; |
13 use Drupal\Core\Url; | 13 use Drupal\Core\Url; |
14 use Drupal\user\SharedTempStoreFactory; | 14 use Drupal\Core\TempStore\SharedTempStoreFactory; |
15 use Drupal\views\Views; | 15 use Drupal\views\Views; |
16 use Symfony\Component\DependencyInjection\ContainerInterface; | 16 use Symfony\Component\DependencyInjection\ContainerInterface; |
17 use Symfony\Component\HttpFoundation\RequestStack; | 17 use Symfony\Component\HttpFoundation\RequestStack; |
18 use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; | |
18 | 19 |
19 /** | 20 /** |
20 * Form controller for the Views edit form. | 21 * Form controller for the Views edit form. |
22 * | |
23 * @internal | |
21 */ | 24 */ |
22 class ViewEditForm extends ViewFormBase { | 25 class ViewEditForm extends ViewFormBase { |
23 | 26 |
24 /** | 27 /** |
25 * The views temp store. | 28 * The views temp store. |
26 * | 29 * |
27 * @var \Drupal\user\SharedTempStore | 30 * @var \Drupal\Core\TempStore\SharedTempStore |
28 */ | 31 */ |
29 protected $tempStore; | 32 protected $tempStore; |
30 | 33 |
31 /** | 34 /** |
32 * The request object. | 35 * The request object. |
50 protected $elementInfo; | 53 protected $elementInfo; |
51 | 54 |
52 /** | 55 /** |
53 * Constructs a new ViewEditForm object. | 56 * Constructs a new ViewEditForm object. |
54 * | 57 * |
55 * @param \Drupal\user\SharedTempStoreFactory $temp_store_factory | 58 * @param \Drupal\Core\TempStore\SharedTempStoreFactory $temp_store_factory |
56 * The factory for the temp store object. | 59 * The factory for the temp store object. |
57 * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack | 60 * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack |
58 * The request stack object. | 61 * The request stack object. |
59 * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter | 62 * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter |
60 * The date Formatter service. | 63 * The date Formatter service. |
71 /** | 74 /** |
72 * {@inheritdoc} | 75 * {@inheritdoc} |
73 */ | 76 */ |
74 public static function create(ContainerInterface $container) { | 77 public static function create(ContainerInterface $container) { |
75 return new static( | 78 return new static( |
76 $container->get('user.shared_tempstore'), | 79 $container->get('tempstore.shared'), |
77 $container->get('request_stack'), | 80 $container->get('request_stack'), |
78 $container->get('date.formatter'), | 81 $container->get('date.formatter'), |
79 $container->get('element_info') | 82 $container->get('element_info') |
80 ); | 83 ); |
81 } | 84 } |
414 } | 417 } |
415 // Add a link to view the page unless the view is disabled or has no | 418 // Add a link to view the page unless the view is disabled or has no |
416 // path. | 419 // path. |
417 elseif ($view->status() && $view->getExecutable()->displayHandlers->get($display['id'])->hasPath()) { | 420 elseif ($view->status() && $view->getExecutable()->displayHandlers->get($display['id'])->hasPath()) { |
418 $path = $view->getExecutable()->displayHandlers->get($display['id'])->getPath(); | 421 $path = $view->getExecutable()->displayHandlers->get($display['id'])->getPath(); |
422 | |
419 if ($path && (strpos($path, '%') === FALSE)) { | 423 if ($path && (strpos($path, '%') === FALSE)) { |
420 if (!parse_url($path, PHP_URL_SCHEME)) { | 424 // Wrap this in a try/catch as trying to generate links to some |
421 // @todo Views should expect and store a leading /. See: | 425 // routes may throw a NotAcceptableHttpException if they do not |
422 // https://www.drupal.org/node/2423913 | 426 // respond to HTML, such as RESTExports. |
423 $url = Url::fromUserInput('/' . ltrim($path, '/')); | 427 try { |
428 if (!parse_url($path, PHP_URL_SCHEME)) { | |
429 // @todo Views should expect and store a leading /. See: | |
430 // https://www.drupal.org/node/2423913 | |
431 $url = Url::fromUserInput('/' . ltrim($path, '/')); | |
432 } | |
433 else { | |
434 $url = Url::fromUri("base:$path"); | |
435 } | |
424 } | 436 } |
425 else { | 437 catch (NotAcceptableHttpException $e) { |
426 $url = Url::fromUri("base:$path"); | 438 $url = '/' . $path; |
427 } | 439 } |
440 | |
428 $build['top']['actions']['path'] = [ | 441 $build['top']['actions']['path'] = [ |
429 '#type' => 'link', | 442 '#type' => 'link', |
430 '#title' => $this->t('View @display_title', ['@display_title' => $display_title]), | 443 '#title' => $this->t('View @display_title', ['@display_title' => $display_title]), |
431 '#options' => ['alt' => [$this->t("Go to the real page for this display")]], | 444 '#options' => ['alt' => [$this->t("Go to the real page for this display")]], |
432 '#url' => $url, | 445 '#url' => $url, |