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 
15 class Link extends \Magento\Framework\View\Element\Html\Link\Current
16 {
20  protected $_registry;
21 
28  public function __construct(
29  \Magento\Framework\View\Element\Template\Context $context,
30  \Magento\Framework\App\DefaultPathInterface $defaultPath,
31  \Magento\Framework\Registry $registry,
32  array $data = []
33  ) {
34  parent::__construct($context, $defaultPath, $data);
35  $this->_registry = $registry;
36  }
37 
43  private function getOrder()
44  {
45  return $this->_registry->registry('current_order');
46  }
47 
53  public function getHref()
54  {
55  return $this->getUrl($this->getPath(), ['order_id' => $this->getOrder()->getId()]);
56  }
57 
63  protected function _toHtml()
64  {
65  if ($this->hasKey()
66  && method_exists($this->getOrder(), 'has' . $this->getKey())
67  && !$this->getOrder()->{'has' . $this->getKey()}()
68  ) {
69  return '';
70  }
71  return parent::_toHtml();
72  }
73 }