Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit a6e4174

Browse files
authored
Merge pull request #136 from itk-dev/feature/token-retry
Added retry task controller action
2 parents 5754b5f + 8bca740 commit a6e4174

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

os2forms_forloeb.routing.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ os2forms_forloeb.forloeb_task_console_controller_execute:
77
_permission: 'access content'
88
options:
99
no_cache: TRUE
10+
11+
os2forms_forloeb.forloeb_task_console_controller_execute_retry:
12+
path: 'os2forms-forloeb/execute-task-retry'
13+
defaults:
14+
_controller: '\Drupal\os2forms_forloeb\Controller\ForloebTaskConsoleController::retry'
15+
_title: 'Task not yet ready'
16+
requirements:
17+
_permission: 'access content'
18+
options:
19+
no_cache: TRUE

src/Controller/ForloebTaskConsoleController.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Drupal\Component\Utility\UrlHelper;
66
use Drupal\Core\Controller\ControllerBase;
77
use Drupal\Core\Entity\EntityTypeManagerInterface;
8+
use Drupal\Core\StringTranslation\StringTranslationTrait;
89
use Drupal\Core\Url;
910
use Drupal\maestro\Engine\MaestroEngine;
1011
use Drupal\maestro\Utility\TaskHandler;
@@ -19,6 +20,8 @@
1920
*/
2021
class ForloebTaskConsoleController extends ControllerBase {
2122

23+
use StringTranslationTrait;
24+
2225
/**
2326
* Update manager service.
2427
*
@@ -82,6 +85,12 @@ public function execute() {
8285
$token = $this->requestStack->getCurrentRequest()->query->get('os2forms-forloeb-ws-token', '');
8386
if ($token) {
8487
$queueRecord = $this->forloebTaskConsole->getQueueIdByWebformSubmissionToken($token);
88+
if (empty($queueRecord)) {
89+
return new RedirectResponse(
90+
Url::fromRoute('os2forms_forloeb.forloeb_task_console_controller_execute_retry',
91+
['referrer' => \Drupal::request()->getRequestUri()])->toString()
92+
);
93+
}
8594
}
8695
else {
8796
// For empty token there is user last task from taskconsole queue.
@@ -150,4 +159,18 @@ public function execute() {
150159
return new RedirectResponse($redirect_to->toString());
151160
}
152161

162+
/**
163+
* Show message about task not yet ready.
164+
*
165+
* @return array
166+
* The render array.
167+
*/
168+
public function retry() {
169+
$referrer = $this->requestStack->getCurrentRequest()->query->get('referrer', '#');
170+
171+
return [
172+
'#markup' => $this->t('Your task is not yet ready. Please <a href=":referrer">try again</a> in 5 minutes.', [':referrer' => $referrer]),
173+
];
174+
}
175+
153176
}

0 commit comments

Comments
 (0)