expo qr code to get visitors email

This commit is contained in:
2021-09-07 00:50:12 +02:00
parent 31790f5ab7
commit 4ea79bca79
28 changed files with 327 additions and 7 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace Drupal\materio_expo\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Url;
/**
* Class QRController.
*/
class QRController extends ControllerBase {
/**
* Hello.
*
* @return string
* Return Hello string.
*/
public function getfile($ref) {
//? https://drupal.stackexchange.com/questions/255216/how-to-do-a-redirectresponse-with-a-destination-query-parameter
//* get node from ref
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
$query = $entity_storage->getQuery()
->condition('type', 'materiau')
->condition('status', '1')
->condition('field_reference', $ref);
$results = $query->execute();
$nid = array_pop($results);
$node = $entity_storage->load($nid);
//* get file from node
$file = $node->get('field_fiche_expo')->referencedEntities()[0];
//* redirect to file
return new RedirectResponse($file->createFileUrl());
// return [
// '#type' => 'markup',
// '#markup' => $this->t("Implement method: getfile with parameter(s): $ref"),
// ];
}
}