public function buildView(FormView $view, FormInterface $form, array $options)
{
if (!isset($options['subject'])) {
return;
}
$subject = $options['subject'];
$shippingCosts = [];
foreach ($view->vars['choices'] as $choiceView) {
$method = $choiceView->data;
if (!$method instanceof ShippingMethodInterface) {
throw new UnexpectedTypeException($method, ShippingMethodInterface::class);
}
$calculator = $this->calculators->get($method->getCalculator());
$shippingCosts[$choiceView->value] = $calculator->calculate($subject, $method->getConfiguration());
}
$view->vars['shipping_costs'] = $shippingCosts;
}