Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Core/Form/ConfirmFormHelper.php
- 9 core/lib/Drupal/Core/Form/ConfirmFormHelper.php
Namespace
Drupal\Core\Form
File
core/lib/Drupal/Core/Form/ConfirmFormHelper.php
View source
<?php
namespace Drupal\Core\Form;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Request;
class ConfirmFormHelper {
public static function buildCancelLink(ConfirmFormInterface $form, Request $request) {
$query = $request->query;
$url = NULL;
if ($query
->has('destination')) {
$options = UrlHelper::parse($query
->get('destination'));
try {
$url = Url::fromUserInput('/' . ltrim($options['path'], '/'), $options);
} catch (\InvalidArgumentException $e) {
}
}
if (!$url) {
$url = $form
->getCancelUrl();
}
return [
'#type' => 'link',
'#title' => $form
->getCancelText(),
'#attributes' => [
'class' => [
'button',
'dialog-cancel',
],
],
'#url' => $url,
'#cache' => [
'contexts' => [
'url.query_args:destination',
],
],
];
}
}
Classes