Link.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * "My Wish List" link
  8. */
  9. namespace Magento\Wishlist\Block;
  10. use Magento\Customer\Block\Account\SortLinkInterface;
  11. /**
  12. * Class Link
  13. *
  14. * @api
  15. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  16. * @since 100.0.2
  17. */
  18. class Link extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface
  19. {
  20. /**
  21. * Template name
  22. *
  23. * @var string
  24. */
  25. protected $_template = 'Magento_Wishlist::link.phtml';
  26. /**
  27. * @var \Magento\Wishlist\Helper\Data
  28. */
  29. protected $_wishlistHelper;
  30. /**
  31. * @param \Magento\Framework\View\Element\Template\Context $context
  32. * @param \Magento\Wishlist\Helper\Data $wishlistHelper
  33. * @param array $data
  34. */
  35. public function __construct(
  36. \Magento\Framework\View\Element\Template\Context $context,
  37. \Magento\Wishlist\Helper\Data $wishlistHelper,
  38. array $data = []
  39. ) {
  40. $this->_wishlistHelper = $wishlistHelper;
  41. parent::__construct($context, $data);
  42. }
  43. /**
  44. * @return string
  45. */
  46. protected function _toHtml()
  47. {
  48. if ($this->_wishlistHelper->isAllow()) {
  49. return parent::_toHtml();
  50. }
  51. return '';
  52. }
  53. /**
  54. * @return string
  55. */
  56. public function getHref()
  57. {
  58. return $this->getUrl('wishlist');
  59. }
  60. /**
  61. * @return \Magento\Framework\Phrase
  62. */
  63. public function getLabel()
  64. {
  65. return __('My Wish List');
  66. }
  67. /**
  68. * {@inheritdoc}
  69. * @since 101.0.0
  70. */
  71. public function getSortOrder()
  72. {
  73. return $this->getData(self::SORT_ORDER);
  74. }
  75. }