#7 - QR Codes & payments

This commit was merged in pull request #22.
This commit is contained in:
Martin Slachta
2026-06-16 19:33:55 +02:00
parent cfbdca238c
commit df5f9b1df4
11 changed files with 251 additions and 72 deletions
@@ -0,0 +1,21 @@
<?php
/** Computes a form's total price as the sum of its elements' prices. */
class RsvFormPriceCalculator {
public function calculate(RsvFormDefinition $definition, RsvFormData $data): float {
global $rsv_form_price_registry;
$total = 0.0;
foreach ($definition->getElements() as $element) {
$calculator = $rsv_form_price_registry->get($element->getType());
if ($calculator === null) {
continue; // Unpriced element type contributes nothing.
}
$total += (float) $calculator($element, $data->getValue($element->getName()));
}
return $total;
}
}