Commit 84eb594f authored by acrollet's avatar acrollet

Allow other modules to alter available units for bee webform submissions

parent 70c4b966
...@@ -55,6 +55,14 @@ function bee_webform_form_submit($form, FormStateInterface $form_state) { ...@@ -55,6 +55,14 @@ function bee_webform_form_submit($form, FormStateInterface $form_state) {
]; ];
if ($node_available_units = bee_webform_get_available_units($values)) { if ($node_available_units = bee_webform_get_available_units($values)) {
// Allow other modules to alter the available units for this node.
$context = [
'form_values' => $value,
'node' => $node,
];
\Drupal::moduleHandler()->alter('bee_webform_available_units', $node_available_units, $context);
if (count($node_available_units) == $value['capacity']) { if (count($node_available_units) == $value['capacity']) {
$available_units = [$node->id() => $node_available_units]; $available_units = [$node->id() => $node_available_units];
break; break;
......
...@@ -91,7 +91,16 @@ class WebformBeeReservationForm extends WebformCompositeBase { ...@@ -91,7 +91,16 @@ class WebformBeeReservationForm extends WebformCompositeBase {
'end_date' => $value['end_date'], 'end_date' => $value['end_date'],
]; ];
$available_units += count(bee_webform_get_available_units($values)); $units = bee_webform_get_available_units($values);
// Allow other modules to alter the available units for this node.
$context = [
'form_values' => $value,
'node' => $node,
];
\Drupal::moduleHandler()->alter('bee_webform_available_units', $units, $context);
$available_units += count($units);
} }
if ($available_units < $value['capacity']) { if ($available_units < $value['capacity']) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment