Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data.php
Go to the documentation of this file.
1 <?php
7 
10 
18 {
22  protected $_stores;
23 
27  protected $_installDate;
28 
32  private $_storeManager;
33 
39  public function __construct(
40  \Magento\Framework\App\Helper\Context $context,
41  \Magento\Store\Model\StoreManagerInterface $storeManager,
43  ) {
44  parent::__construct(
45  $context
46  );
48  $this->_storeManager = $storeManager;
49  }
50 
56  public function getStores()
57  {
58  if (!$this->_stores) {
59  $this->_stores = $this->_storeManager->getStore()->getResourceCollection()->load();
60  }
61  return $this->_stores;
62  }
63 
69  public function countStores()
70  {
71  return sizeof($this->_stores->getItems());
72  }
73 
79  public function getDatePeriods()
80  {
81  return [
82  '24h' => __('Last 24 Hours'),
83  '7d' => __('Last 7 Days'),
84  '1m' => __('Current Month'),
85  '1y' => __('YTD'),
86  '2y' => __('2YTD')
87  ];
88  }
89 
97  public function getChartDataHash($data)
98  {
99  $secret = $this->_installDate;
100  return md5($data . $secret);
101  }
102 }
$storeManager
__()
Definition: __.php:13
$deploymentConfig
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, DeploymentConfig $deploymentConfig)
Definition: Data.php:39