-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebform_product.module
32 lines (28 loc) · 1.13 KB
/
webform_product.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform_product\WebFormProductFormHelper;
/**
* Implements hook_element_info_alter().
*/
function webform_product_element_info_alter(array &$info) {
$definitions = \Drupal::service('plugin.manager.webform_product')->getDefinitions();
foreach ($definitions as $id => $definition) {
/** @var \Drupal\Component\Plugin\PluginManagerInterface $pluginManager */
if (isset($info[$id])) {
$info[$id]['#process'][] = [DefaultFactory::getPluginClass($id, $definition), 'process'];
}
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function webform_product_form_webform_ui_element_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['properties']['element']['#process'][] = [WebFormProductFormHelper::class, 'processElementForm'];
}
/**
* Implements hook_webform_submission_form_alter().
*/
function webform_product_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
$form['actions']['submit']['#submit'][] = [WebFormProductFormHelper::class, 'submissionToCart'];
}