Link.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Guest;
  7. use Magento\Customer\Model\Context;
  8. /**
  9. * "Orders and Returns" link
  10. *
  11. * @api
  12. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  13. * @since 100.0.2
  14. */
  15. class Link extends \Magento\Framework\View\Element\Html\Link\Current
  16. {
  17. /**
  18. * @var \Magento\Framework\App\Http\Context
  19. */
  20. protected $httpContext;
  21. /**
  22. * @param \Magento\Framework\View\Element\Template\Context $context
  23. * @param \Magento\Framework\App\DefaultPathInterface $defaultPath
  24. * @param \Magento\Framework\App\Http\Context $httpContext
  25. * @param array $data
  26. */
  27. public function __construct(
  28. \Magento\Framework\View\Element\Template\Context $context,
  29. \Magento\Framework\App\DefaultPathInterface $defaultPath,
  30. \Magento\Framework\App\Http\Context $httpContext,
  31. array $data = []
  32. ) {
  33. parent::__construct($context, $defaultPath, $data);
  34. $this->httpContext = $httpContext;
  35. }
  36. /**
  37. * @return string
  38. */
  39. protected function _toHtml()
  40. {
  41. if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
  42. return '';
  43. }
  44. return parent::_toHtml();
  45. }
  46. }