Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Bar.php
Go to the documentation of this file.
1 <?php
7 
13 class Bar extends \Magento\Backend\Block\Dashboard\AbstractDashboard
14 {
18  protected $_totals = [];
19 
23  protected $_currentCurrencyCode = null;
24 
28  public function getTotals()
29  {
30  return $this->_totals;
31  }
32 
39  public function addTotal($label, $value, $isQuantity = false)
40  {
41  if (!$isQuantity) {
42  $value = $this->format($value);
43  }
44  $decimals = '';
45  $this->_totals[] = ['label' => $label, 'value' => $value, 'decimals' => $decimals];
46 
47  return $this;
48  }
49 
56  public function format($price)
57  {
58  return $this->getCurrency()->format($price);
59  }
60 
67  public function setCurrency($currency)
68  {
69  $this->_currency = $currency;
70  }
71 
77  public function getCurrency()
78  {
79  if ($this->_currentCurrencyCode === null) {
80  if ($this->getRequest()->getParam('store')) {
81  $this->_currentCurrencyCode = $this->_storeManager->getStore(
82  $this->getRequest()->getParam('store')
83  )->getBaseCurrency();
84  } elseif ($this->getRequest()->getParam('website')) {
85  $this->_currentCurrencyCode = $this->_storeManager->getWebsite(
86  $this->getRequest()->getParam('website')
87  )->getBaseCurrency();
88  } elseif ($this->getRequest()->getParam('group')) {
89  $this->_currentCurrencyCode = $this->_storeManager->getGroup(
90  $this->getRequest()->getParam('group')
91  )->getWebsite()->getBaseCurrency();
92  } else {
93  $this->_currentCurrencyCode = $this->_storeManager->getStore()->getBaseCurrency();
94  }
95  }
96 
98  }
99 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$price
$label
Definition: details.phtml:21
$value
Definition: gender.phtml:16
addTotal($label, $value, $isQuantity=false)
Definition: Bar.php:39