Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PriceBox.php
Go to the documentation of this file.
1 <?php
7 
12 use Magento\Framework\Pricing\Render\PriceBox as PriceBoxRender;
15 
22 class PriceBox extends PriceBoxRender
23 {
27  protected $jsonHelper;
28 
32  protected $mathRandom;
33 
44  public function __construct(
45  Context $context,
51  array $data = []
52  ) {
53  $this->jsonHelper = $jsonHelper;
54  $this->mathRandom = $mathRandom;
55  parent::__construct($context, $saleableItem, $price, $rendererPool);
56  }
57 
64  public function jsonEncode($valueToEncode)
65  {
66  return $this->jsonHelper->jsonEncode($valueToEncode);
67  }
68 
76  public function getRandomString($length, $chars = null)
77  {
78  return $this->mathRandom->getRandomString($length, $chars);
79  }
80 
89  {
90  //TODO Refactor - change to const similar to Model\Product\Type\Grouped::TYPE_CODE
91  if ($product->getTypeId() == 'grouped') {
92  return false;
93  }
94  return true;
95  }
96 }
__construct(Context $context, Product $saleableItem, PriceInterface $price, RendererPool $rendererPool, Data $jsonHelper, Random $mathRandom, array $data=[])
Definition: PriceBox.php:44
getRandomString($length, $chars=null)
Definition: PriceBox.php:76