|
10 | 10 | use Drupal\key_auth\Authentication\Provider\KeyAuth; |
11 | 11 | use Drupal\webform\WebformInterface; |
12 | 12 | use Drupal\webform\WebformSubmissionInterface; |
| 13 | +use Symfony\Component\HttpFoundation\RequestStack; |
13 | 14 |
|
14 | 15 | /** |
15 | 16 | * Webform helper for helping with webforms. |
@@ -38,13 +39,21 @@ class WebformHelper { |
38 | 39 | */ |
39 | 40 | private KeyAuth $keyAuth; |
40 | 41 |
|
| 42 | + /** |
| 43 | + * The request stack. |
| 44 | + * |
| 45 | + * @var \Symfony\Component\HttpFoundation\RequestStack |
| 46 | + */ |
| 47 | + private RequestStack $requestStack; |
| 48 | + |
41 | 49 | /** |
42 | 50 | * Constructor. |
43 | 51 | */ |
44 | | - public function __construct(EntityTypeManagerInterface $entityTypeManager, AccountProxyInterface $currentUser, KeyAuth $keyAuth) { |
| 52 | + public function __construct(EntityTypeManagerInterface $entityTypeManager, AccountProxyInterface $currentUser, KeyAuth $keyAuth, RequestStack $requestStack) { |
45 | 53 | $this->entityTypeManager = $entityTypeManager; |
46 | 54 | $this->currentUser = $currentUser; |
47 | 55 | $this->keyAuth = $keyAuth; |
| 56 | + $this->requestStack = $requestStack; |
48 | 57 | } |
49 | 58 |
|
50 | 59 | /** |
@@ -244,7 +253,7 @@ private function loadUsers(array $spec): array { |
244 | 253 | * @phpstan-return int|array<string, string>|null |
245 | 254 | */ |
246 | 255 | public function fileDownload(string $uri) { |
247 | | - $request = \Drupal::request(); |
| 256 | + $request = $this->requestStack->getCurrentRequest(); |
248 | 257 |
|
249 | 258 | if ($user = $this->keyAuth->authenticate($request)) { |
250 | 259 | // Find webform id from uri, see example uri. |
|
0 commit comments