|
5 | 5 | use Drupal\Component\Utility\UrlHelper; |
6 | 6 | use Drupal\Core\Controller\ControllerBase; |
7 | 7 | use Drupal\Core\Entity\EntityTypeManagerInterface; |
| 8 | +use Drupal\Core\StringTranslation\StringTranslationTrait; |
8 | 9 | use Drupal\Core\Url; |
9 | 10 | use Drupal\maestro\Engine\MaestroEngine; |
10 | 11 | use Drupal\maestro\Utility\TaskHandler; |
|
19 | 20 | */ |
20 | 21 | class ForloebTaskConsoleController extends ControllerBase { |
21 | 22 |
|
| 23 | + use StringTranslationTrait; |
| 24 | + |
22 | 25 | /** |
23 | 26 | * Update manager service. |
24 | 27 | * |
@@ -82,6 +85,12 @@ public function execute() { |
82 | 85 | $token = $this->requestStack->getCurrentRequest()->query->get('os2forms-forloeb-ws-token', ''); |
83 | 86 | if ($token) { |
84 | 87 | $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 | + } |
85 | 94 | } |
86 | 95 | else { |
87 | 96 | // For empty token there is user last task from taskconsole queue. |
@@ -150,4 +159,18 @@ public function execute() { |
150 | 159 | return new RedirectResponse($redirect_to->toString()); |
151 | 160 | } |
152 | 161 |
|
| 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 | + |
153 | 176 | } |
0 commit comments