/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/Pricing/PriceComposite.php
70 строк
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 17:47
22 окт 2025, 17:47
1b769b7
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Framework\Pricing; use Magento\Framework\Pricing\Price\Factory as PriceFactory; use Magento\Framework\Pricing\Price\PriceInterface; /** * Composite price model */ class PriceComposite { /** * @var PriceFactory */ protected $priceFactory; /** * @var array */ protected $metadata; /** * @param PriceFactory $priceFactory * @param array $metadata */ public function __construct(PriceFactory $priceFactory, array $metadata = []) { $this->priceFactory = $priceFactory; $this->metadata = $metadata; } /** * @return array */ public function getPriceCodes() { return array_keys($this->metadata); } /** * Returns metadata for prices * * @return array */ public function getMetadata() { return $this->metadata; } /** * @param SaleableInterface $salableItem * @param string $priceCode * @param float $quantity * @return PriceInterface * @throws \InvalidArgumentException */ public function createPriceObject(SaleableInterface $salableItem, $priceCode, $quantity) { if (!isset($this->metadata[$priceCode])) { throw new \InvalidArgumentException($priceCode . ' is not registered in prices list'); } $className = $this->metadata[$priceCode]['class']; return $this->priceFactory->create($salableItem, $className, $quantity); } }