Sonata\ProductBundle\Model\BaseProductProvider::calculatePrice PHP Метод

calculatePrice() публичный Метод

public calculatePrice ( Sonata\Component\Product\ProductInterface $product, Sonata\Component\Currency\CurrencyInterface $currency, $vat = false, $quantity = 1 )
$product Sonata\Component\Product\ProductInterface
$currency Sonata\Component\Currency\CurrencyInterface
    public function calculatePrice(ProductInterface $product, CurrencyInterface $currency, $vat = false, $quantity = 1)
    {
        $event = new BeforeCalculatePriceEvent($product, $currency, $vat, $quantity);
        $this->getEventDispatcher()->dispatch(BasketEvents::PRE_CALCULATE_PRICE, $event);
        $vat = $event->getVat();
        $quantity = $event->getQuantity();
        if (!is_int($quantity) || $quantity < 1) {
            throw new InvalidParameterException('Expected integer >= 1 for quantity, ' . $quantity . ' given.');
        }
        $price = floatval(bcmul($this->currencyPriceCalculator->getPrice($product, $currency, $vat), $quantity));
        $afterEvent = new AfterCalculatePriceEvent($product, $currency, $vat, $quantity, $price);
        $this->getEventDispatcher()->dispatch(BasketEvents::POST_CALCULATE_PRICE, $afterEvent);
        return $afterEvent->getPrice();
    }