Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Factory.php
Go to the documentation of this file.
1 <?php
8 
10 
14 class Factory
15 {
21  protected $objectManager;
22 
29  {
30  $this->objectManager = $objectManager;
31  }
32 
43  public function create(SaleableInterface $saleableItem, $className, $quantity, array $arguments = [])
44  {
45  $arguments['saleableItem'] = $saleableItem;
46  $arguments['quantity'] = $quantity;
47  $price = $this->objectManager->create($className, $arguments);
48  if (!$price instanceof PriceInterface) {
49  throw new \InvalidArgumentException(
50  $className . ' doesn\'t implement \Magento\Framework\Pricing\Price\PriceInterface'
51  );
52  }
53  return $price;
54  }
55 }
$price
create(SaleableInterface $saleableItem, $className, $quantity, array $arguments=[])
Definition: Factory.php:43
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
Definition: Factory.php:28
$arguments
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31