Sylius\Bundle\ShippingBundle\Form\Type\ShippingMethodChoiceType::buildView PHP Method

buildView() public method

public buildView ( Symfony\Component\Form\FormView $view, Symfony\Component\Form\FormInterface $form, array $options )
$view Symfony\Component\Form\FormView
$form Symfony\Component\Form\FormInterface
$options array
    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;
    }