check in controller if form was submited in this session

This commit is contained in:
Bachir Soussi Chiadmi 2021-09-07 00:52:59 +02:00
parent 4ea79bca79
commit e6f0cbb190
1 changed files with 23 additions and 17 deletions

View File

@ -20,6 +20,10 @@ class QRController extends ControllerBase {
public function getfile($ref) {
//? https://drupal.stackexchange.com/questions/255216/how-to-do-a-redirectresponse-with-a-destination-query-parameter
//* check if email cookie is present (form submitted)
$session = \Drupal::request()->getSession();
$alreadysetemail = $session->get('materio_expo_email');
if($alreadysetemail){
//* get node from ref
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
$query = $entity_storage->getQuery()
@ -36,10 +40,12 @@ class QRController extends ControllerBase {
//* redirect to file
return new RedirectResponse($file->createFileUrl());
// return [
// '#type' => 'markup',
// '#markup' => $this->t("Implement method: getfile with parameter(s): $ref"),
// ];
} else {
return [
'#type' => 'markup',
'#markup' => $this->t("Error, email not provided"),
];
}
}
}