expo qr code to get visitors email
This commit is contained in:
		@@ -1,4 +0,0 @@
 | 
			
		||||
dependencies:
 | 
			
		||||
  enforced:
 | 
			
		||||
    module:
 | 
			
		||||
      - devel
 | 
			
		||||
@@ -7,6 +7,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -119,6 +120,7 @@ third_party_settings:
 | 
			
		||||
    group_files:
 | 
			
		||||
      children:
 | 
			
		||||
        - field_attachments
 | 
			
		||||
        - field_fiche_expo
 | 
			
		||||
      parent_name: group_htabs
 | 
			
		||||
      weight: 13
 | 
			
		||||
      format_type: tab
 | 
			
		||||
@@ -223,6 +225,13 @@ content:
 | 
			
		||||
    third_party_settings: {  }
 | 
			
		||||
    type: options_select
 | 
			
		||||
    region: content
 | 
			
		||||
  field_fiche_expo:
 | 
			
		||||
    weight: 18
 | 
			
		||||
    settings:
 | 
			
		||||
      progress_indicator: throbber
 | 
			
		||||
    third_party_settings: {  }
 | 
			
		||||
    type: file_generic
 | 
			
		||||
    region: content
 | 
			
		||||
  field_linked_articles:
 | 
			
		||||
    weight: 19
 | 
			
		||||
    settings:
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -207,5 +208,7 @@ content:
 | 
			
		||||
      link_to_entity: false
 | 
			
		||||
    third_party_settings: {  }
 | 
			
		||||
hidden:
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  langcode: true
 | 
			
		||||
  search_api_excerpt: true
 | 
			
		||||
  synonyms: true
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -207,5 +208,7 @@ content:
 | 
			
		||||
      link_to_entity: false
 | 
			
		||||
    third_party_settings: {  }
 | 
			
		||||
hidden:
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  langcode: true
 | 
			
		||||
  search_api_excerpt: true
 | 
			
		||||
  synonyms: true
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -77,6 +78,7 @@ hidden:
 | 
			
		||||
  field_attachments: true
 | 
			
		||||
  field_distributor: true
 | 
			
		||||
  field_famille: true
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  field_index: true
 | 
			
		||||
  field_linked_articles: true
 | 
			
		||||
  field_linked_materials: true
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -72,6 +73,7 @@ hidden:
 | 
			
		||||
  body: true
 | 
			
		||||
  field_attachments: true
 | 
			
		||||
  field_distributor: true
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  field_index: true
 | 
			
		||||
  field_linked_articles: true
 | 
			
		||||
  field_linked_materials: true
 | 
			
		||||
@@ -88,3 +90,4 @@ hidden:
 | 
			
		||||
  langcode: true
 | 
			
		||||
  links: true
 | 
			
		||||
  search_api_excerpt: true
 | 
			
		||||
  synonyms: true
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -72,6 +73,7 @@ hidden:
 | 
			
		||||
  body: true
 | 
			
		||||
  field_attachments: true
 | 
			
		||||
  field_distributor: true
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  field_index: true
 | 
			
		||||
  field_linked_articles: true
 | 
			
		||||
  field_linked_materials: true
 | 
			
		||||
@@ -88,3 +90,4 @@ hidden:
 | 
			
		||||
  langcode: true
 | 
			
		||||
  links: true
 | 
			
		||||
  search_api_excerpt: true
 | 
			
		||||
  synonyms: true
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -155,6 +156,7 @@ content:
 | 
			
		||||
    third_party_settings: {  }
 | 
			
		||||
hidden:
 | 
			
		||||
  field_famille: true
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  field_index: true
 | 
			
		||||
  field_localisation_old: true
 | 
			
		||||
  field_memo: true
 | 
			
		||||
@@ -170,3 +172,4 @@ hidden:
 | 
			
		||||
  flag_projet_2: true
 | 
			
		||||
  langcode: true
 | 
			
		||||
  search_api_excerpt: true
 | 
			
		||||
  synonyms: true
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -128,6 +129,7 @@ content:
 | 
			
		||||
hidden:
 | 
			
		||||
  field_attachments: true
 | 
			
		||||
  field_famille: true
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  field_index: true
 | 
			
		||||
  field_linked_articles: true
 | 
			
		||||
  field_linked_materials: true
 | 
			
		||||
@@ -146,3 +148,4 @@ hidden:
 | 
			
		||||
  langcode: true
 | 
			
		||||
  links: true
 | 
			
		||||
  search_api_excerpt: true
 | 
			
		||||
  synonyms: true
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ dependencies:
 | 
			
		||||
    - field.field.node.materiau.field_attachments
 | 
			
		||||
    - field.field.node.materiau.field_distributor
 | 
			
		||||
    - field.field.node.materiau.field_famille
 | 
			
		||||
    - field.field.node.materiau.field_fiche_expo
 | 
			
		||||
    - field.field.node.materiau.field_index
 | 
			
		||||
    - field.field.node.materiau.field_linked_articles
 | 
			
		||||
    - field.field.node.materiau.field_linked_materials
 | 
			
		||||
@@ -67,6 +68,7 @@ hidden:
 | 
			
		||||
  field_attachments: true
 | 
			
		||||
  field_distributor: true
 | 
			
		||||
  field_famille: true
 | 
			
		||||
  field_fiche_expo: true
 | 
			
		||||
  field_index: true
 | 
			
		||||
  field_linked_articles: true
 | 
			
		||||
  field_linked_materials: true
 | 
			
		||||
@@ -83,3 +85,4 @@ hidden:
 | 
			
		||||
  langcode: true
 | 
			
		||||
  links: true
 | 
			
		||||
  search_api_excerpt: true
 | 
			
		||||
  synonyms: true
 | 
			
		||||
 
 | 
			
		||||
@@ -126,6 +126,7 @@ module:
 | 
			
		||||
  mailsystem: 0
 | 
			
		||||
  materio_commerce: 0
 | 
			
		||||
  materio_decoupled: 0
 | 
			
		||||
  materio_expo: 0
 | 
			
		||||
  materio_flag: 0
 | 
			
		||||
  materio_graphql: 0
 | 
			
		||||
  materio_home: 0
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								config/sync/field.field.node.materiau.field_fiche_expo.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								config/sync/field.field.node.materiau.field_fiche_expo.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
uuid: c31ef185-cef1-4e63-a11e-af52be3d4dfa
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies:
 | 
			
		||||
  config:
 | 
			
		||||
    - field.storage.node.field_fiche_expo
 | 
			
		||||
    - node.type.materiau
 | 
			
		||||
  module:
 | 
			
		||||
    - file
 | 
			
		||||
id: node.materiau.field_fiche_expo
 | 
			
		||||
field_name: field_fiche_expo
 | 
			
		||||
entity_type: node
 | 
			
		||||
bundle: materiau
 | 
			
		||||
label: 'Fiche expo'
 | 
			
		||||
description: ''
 | 
			
		||||
required: false
 | 
			
		||||
translatable: false
 | 
			
		||||
default_value: {  }
 | 
			
		||||
default_value_callback: ''
 | 
			
		||||
settings:
 | 
			
		||||
  file_directory: fichesexpo
 | 
			
		||||
  file_extensions: pdf
 | 
			
		||||
  max_filesize: ''
 | 
			
		||||
  description_field: false
 | 
			
		||||
  handler: 'default:file'
 | 
			
		||||
  handler_settings: {  }
 | 
			
		||||
field_type: file
 | 
			
		||||
							
								
								
									
										27
									
								
								config/sync/field.storage.node.field_fiche_expo.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								config/sync/field.storage.node.field_fiche_expo.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
uuid: beb03fa0-82d7-492e-890e-e2d623d5f12e
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies:
 | 
			
		||||
  module:
 | 
			
		||||
    - field_permissions
 | 
			
		||||
    - file
 | 
			
		||||
    - node
 | 
			
		||||
third_party_settings:
 | 
			
		||||
  field_permissions:
 | 
			
		||||
    permission_type: public
 | 
			
		||||
id: node.field_fiche_expo
 | 
			
		||||
field_name: field_fiche_expo
 | 
			
		||||
entity_type: node
 | 
			
		||||
type: file
 | 
			
		||||
settings:
 | 
			
		||||
  display_field: false
 | 
			
		||||
  display_default: false
 | 
			
		||||
  uri_scheme: public
 | 
			
		||||
  target_type: file
 | 
			
		||||
module: file
 | 
			
		||||
locked: false
 | 
			
		||||
cardinality: 1
 | 
			
		||||
translatable: true
 | 
			
		||||
indexes: {  }
 | 
			
		||||
persist_with_no_fields: false
 | 
			
		||||
custom_storage: false
 | 
			
		||||
							
								
								
									
										20
									
								
								config/sync/gdpr_fields.gdpr_fields_config.config_pages.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								config/sync/gdpr_fields.gdpr_fields_config.config_pages.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
uuid: 2f397526-c832-45eb-880d-592eaa058462
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies: {  }
 | 
			
		||||
id: config_pages
 | 
			
		||||
bundles:
 | 
			
		||||
  expo_fiches:
 | 
			
		||||
    field_fiches:
 | 
			
		||||
      bundle: expo_fiches
 | 
			
		||||
      name: field_fiches
 | 
			
		||||
      entity_type_id: config_pages
 | 
			
		||||
      rtf: 'no'
 | 
			
		||||
      rta: 'no'
 | 
			
		||||
      enabled: false
 | 
			
		||||
      anonymizer: ''
 | 
			
		||||
      notes: ''
 | 
			
		||||
      relationship: 0
 | 
			
		||||
      sars_filename: ''
 | 
			
		||||
filenames:
 | 
			
		||||
  expo_fiches: ''
 | 
			
		||||
@@ -40,7 +40,20 @@ bundles:
 | 
			
		||||
      notes: ''
 | 
			
		||||
      relationship: 0
 | 
			
		||||
      sars_filename: ''
 | 
			
		||||
  materiau:
 | 
			
		||||
    field_fiche_expo:
 | 
			
		||||
      bundle: materiau
 | 
			
		||||
      name: field_fiche_expo
 | 
			
		||||
      entity_type_id: node
 | 
			
		||||
      rtf: 'no'
 | 
			
		||||
      rta: 'no'
 | 
			
		||||
      enabled: false
 | 
			
		||||
      anonymizer: ''
 | 
			
		||||
      notes: ''
 | 
			
		||||
      relationship: 0
 | 
			
		||||
      sars_filename: ''
 | 
			
		||||
filenames:
 | 
			
		||||
  thematique: ''
 | 
			
		||||
  simplenews_issue: ''
 | 
			
		||||
  frontpage: ''
 | 
			
		||||
  materiau: ''
 | 
			
		||||
 
 | 
			
		||||
@@ -108,6 +108,7 @@ permissions:
 | 
			
		||||
  - 'edit any simplenews_issue content'
 | 
			
		||||
  - 'edit any static content'
 | 
			
		||||
  - 'edit any thematique content'
 | 
			
		||||
  - 'edit expo_fiches config page entity'
 | 
			
		||||
  - 'edit field_company'
 | 
			
		||||
  - 'edit field_member_type'
 | 
			
		||||
  - 'edit field_memo'
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@ permissions:
 | 
			
		||||
  - 'subscribe to newsletters'
 | 
			
		||||
  - 'use text format wysiwyg'
 | 
			
		||||
  - 'view commerce_product'
 | 
			
		||||
  - 'view expo_fiches config page entity'
 | 
			
		||||
  - 'view field_showroom_files'
 | 
			
		||||
  - 'view materio_product_type commerce_product'
 | 
			
		||||
  - 'view privacy_policy config page entity'
 | 
			
		||||
 
 | 
			
		||||
@@ -41,6 +41,7 @@ permissions:
 | 
			
		||||
  - 'use chutier'
 | 
			
		||||
  - 'use text format wysiwyg'
 | 
			
		||||
  - 'view commerce_product'
 | 
			
		||||
  - 'view expo_fiches config page entity'
 | 
			
		||||
  - 'view field_showroom_files'
 | 
			
		||||
  - 'view materio_product_type commerce_product'
 | 
			
		||||
  - 'view own commerce_order'
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1 @@
 | 
			
		||||
materio_expo:
 | 
			
		||||
							
								
								
									
										5
									
								
								web/modules/custom/materio_expo/materio_expo.info.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								web/modules/custom/materio_expo/materio_expo.info.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
name: 'materio_expo'
 | 
			
		||||
type: module
 | 
			
		||||
description: 'My Awesome Module'
 | 
			
		||||
core: 8.x
 | 
			
		||||
package: 'Materio'
 | 
			
		||||
							
								
								
									
										37
									
								
								web/modules/custom/materio_expo/materio_expo.module
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								web/modules/custom/materio_expo/materio_expo.module
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file
 | 
			
		||||
 * Contains materio_expo.module.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
use Drupal\Core\Routing\RouteMatchInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Implements hook_help().
 | 
			
		||||
 */
 | 
			
		||||
function materio_expo_help($route_name, RouteMatchInterface $route_match) {
 | 
			
		||||
  switch ($route_name) {
 | 
			
		||||
    // Main module help for the materio_expo module.
 | 
			
		||||
    case 'help.page.materio_expo':
 | 
			
		||||
      $output = '';
 | 
			
		||||
      $output .= '<h3>' . t('About') . '</h3>';
 | 
			
		||||
      $output .= '<p>' . t('My Awesome Module') . '</p>';
 | 
			
		||||
      return $output;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* Implements hook_mail().
 | 
			
		||||
*/
 | 
			
		||||
function materio_expo_mail($key, &$message, $params) {
 | 
			
		||||
  switch ($key) {
 | 
			
		||||
    case 'expo_getmail_submitted':
 | 
			
		||||
      $message['from'] = \Drupal::config('system.site')->get('mail');
 | 
			
		||||
      $message['subject'] = t('[EXPO] mail submitted: @mail', array('@mail' => $params['mail']));
 | 
			
		||||
      $message['body'][] = $params['message'];
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 }
 | 
			
		||||
							
								
								
									
										14
									
								
								web/modules/custom/materio_expo/materio_expo.routing.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								web/modules/custom/materio_expo/materio_expo.routing.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
materio_expo.qr_controller_getfile:
 | 
			
		||||
  path: '/materio_expo/qr/file/{ref}'
 | 
			
		||||
  defaults:
 | 
			
		||||
    _controller: '\Drupal\materio_expo\Controller\QRController::getfile'
 | 
			
		||||
    # _title: 'Get File'
 | 
			
		||||
  requirements:
 | 
			
		||||
    _permission: 'access content'
 | 
			
		||||
materio_expo.get_email:
 | 
			
		||||
  path: '/materio_expo/qr/form/{ref}'
 | 
			
		||||
  defaults:
 | 
			
		||||
    _form: '\Drupal\materio_expo\Form\GetEmail'
 | 
			
		||||
    # _title: ''
 | 
			
		||||
  requirements:
 | 
			
		||||
    _access: 'TRUE'
 | 
			
		||||
@@ -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"),
 | 
			
		||||
    // ];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										98
									
								
								web/modules/custom/materio_expo/src/Form/GetEmail.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								web/modules/custom/materio_expo/src/Form/GetEmail.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,98 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Drupal\materio_expo\Form;
 | 
			
		||||
 | 
			
		||||
use Drupal\Core\Form\FormBase;
 | 
			
		||||
use Drupal\Core\Form\FormStateInterface;
 | 
			
		||||
// use Symfony\Component\HttpFoundation\Cookie;
 | 
			
		||||
use Symfony\Component\HttpFoundation\RedirectResponse;
 | 
			
		||||
use Drupal\Core\Url;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class GetEmail.
 | 
			
		||||
 */
 | 
			
		||||
class GetEmail extends FormBase {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function getFormId() {
 | 
			
		||||
    return 'get_email';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function buildForm(array $form, FormStateInterface $form_state, $ref = null) {
 | 
			
		||||
    
 | 
			
		||||
    // check if email cookie is already present
 | 
			
		||||
    $session = \Drupal::request()->getSession();
 | 
			
		||||
    $alreadysetemail = $session->get('materio_expo_email');
 | 
			
		||||
    if($alreadysetemail){
 | 
			
		||||
      // https://x-team.com/blog/drupal-goto/
 | 
			
		||||
      $url = Url::fromRoute('materio_expo.qr_controller_getfile', ['ref'=>$ref], ['absolute' => TRUE]);
 | 
			
		||||
      return new RedirectResponse($url->toString());
 | 
			
		||||
    }else{
 | 
			
		||||
      $form['email'] = [
 | 
			
		||||
        '#type' => 'email',
 | 
			
		||||
        // '#title' => $this->t('Email'),
 | 
			
		||||
        '#attributes' => [
 | 
			
		||||
          'placeholder' => $this->t('Email')
 | 
			
		||||
        ],
 | 
			
		||||
        '#weight' => '0',
 | 
			
		||||
      ];
 | 
			
		||||
      
 | 
			
		||||
      $form['ref'] = [
 | 
			
		||||
        '#type' => 'hidden',
 | 
			
		||||
        '#value' => $ref
 | 
			
		||||
      ];
 | 
			
		||||
  
 | 
			
		||||
      $form['submit'] = [
 | 
			
		||||
        '#type' => 'submit',
 | 
			
		||||
        '#value' => $this->t("Submit"),
 | 
			
		||||
      ];
 | 
			
		||||
      return $form;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function validateForm(array &$form, FormStateInterface $form_state) {
 | 
			
		||||
    parent::validateForm($form, $form_state);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * {@inheritdoc}
 | 
			
		||||
   */
 | 
			
		||||
  public function submitForm(array &$form, FormStateInterface $form_state) {
 | 
			
		||||
    $values = $form_state->getValues();
 | 
			
		||||
 | 
			
		||||
    //* send form submission by email
 | 
			
		||||
    $mailManager = \Drupal::service('plugin.manager.mail');
 | 
			
		||||
    $module = 'materio_expo';
 | 
			
		||||
    $key = 'expo_getmail_submitted';
 | 
			
		||||
    $to = \Drupal::config('system.site')->get('mail');
 | 
			
		||||
    $params['mail'] = $values['mail'];
 | 
			
		||||
    $params['message'] = $values['mail'];
 | 
			
		||||
    $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
 | 
			
		||||
    $send = true;
 | 
			
		||||
 | 
			
		||||
    $result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
 | 
			
		||||
    if ($result['result'] !== true) {
 | 
			
		||||
      $logger = \Drupal::logger('flag_lists');
 | 
			
		||||
      $logger->error('There was a problem sending your message.' . $values['mail']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //* record email as session variable
 | 
			
		||||
    // https://drupal.stackexchange.com/questions/197576/storing-data-session-for-anonymous-user
 | 
			
		||||
    $session = \Drupal::request()->getSession();
 | 
			
		||||
    $session->set('materio_expo_email', true);
 | 
			
		||||
 | 
			
		||||
    //* redirect to getfile controller
 | 
			
		||||
    $ref = $values['ref'];
 | 
			
		||||
    $form_state->setRedirect('materio_expo.qr_controller_getfile', ['ref'=>$ref]);
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -97,6 +97,7 @@ export let _v_sitebranding_block, _v_user_block, _v_header_menu,
 | 
			
		||||
          drupalDecoupled.route_name.indexOf('user') !== -1 ||
 | 
			
		||||
          drupalDecoupled.route_name.indexOf('entity.webform.canonical') !== -1 ||
 | 
			
		||||
          drupalDecoupled.route_name.indexOf('entity.webform.confirmation') !== -1 ||
 | 
			
		||||
          drupalDecoupled.route_name.indexOf('materio_expo.qr_controller_getfile') !== -1 ||
 | 
			
		||||
          (drupalDecoupled.route_name === 'entity.node.canonical' && drupalDecoupled.entity_bundle === 'simplenews_issue')
 | 
			
		||||
      ) {
 | 
			
		||||
        console.debug('NO VUEJS')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user