Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Link.php
Go to the documentation of this file.
1 <?php
7 
14 {
18  protected $_moduleManager;
19 
23  protected $_cartHelper;
24 
32  public function __construct(
33  \Magento\Framework\View\Element\Template\Context $context,
34  \Magento\Framework\Module\Manager $moduleManager,
35  \Magento\Checkout\Helper\Cart $cartHelper,
36  array $data = []
37  ) {
38  $this->_cartHelper = $cartHelper;
39  parent::__construct($context, $data);
40  $this->_moduleManager = $moduleManager;
41  }
42 
47  public function getLabel()
48  {
49  return $this->_createLabel($this->_getItemCount());
50  }
51 
56  public function getHref()
57  {
58  return $this->getUrl('checkout/cart');
59  }
60 
66  protected function _toHtml()
67  {
68  if (!$this->_moduleManager->isOutputEnabled('Magento_Checkout')) {
69  return '';
70  }
71  return parent::_toHtml();
72  }
73 
79  protected function _getItemCount()
80  {
81  $count = $this->getSummaryQty();
82  return $count ? $count : $this->_cartHelper->getSummaryCount();
83  }
84 
91  protected function _createLabel($count)
92  {
93  if ($count == 1) {
94  return __('My Cart (1 item)');
95  } elseif ($count > 0) {
96  return __('My Cart (%1 items)', $count);
97  } else {
98  return __('My Cart');
99  }
100  }
101 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$count
Definition: recent.phtml:13
__()
Definition: __.php:13
$moduleManager
Definition: products.php:75