Link.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Block;
  9. /**
  10. * Class Link
  11. */
  12. class Link extends \Magento\Framework\View\Element\Html\Link
  13. {
  14. /**
  15. * @var \Magefan\Blog\Model\Url
  16. */
  17. protected $_url;
  18. /**
  19. * @param \Magento\Framework\View\Element\Template\Context $context
  20. * @param \Magefan\Blog\Model\Url $url
  21. * @param array $data
  22. */
  23. public function __construct(
  24. \Magento\Framework\View\Element\Template\Context $context,
  25. \Magefan\Blog\Model\Url $url,
  26. array $data = []
  27. ) {
  28. $this->_url = $url;
  29. parent::__construct($context, $data);
  30. }
  31. /**
  32. * @return string
  33. */
  34. public function getHref()
  35. {
  36. return $this->_url->getBaseUrl();
  37. }
  38. /**
  39. * @return string
  40. */
  41. public function getLabel()
  42. {
  43. return $this->_scopeConfig->getValue(
  44. 'mfblog/index_page/title',
  45. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  46. );
  47. }
  48. /**
  49. * Render block HTML
  50. *
  51. * @return string
  52. */
  53. protected function _toHtml()
  54. {
  55. if (!$this->_scopeConfig->getValue(
  56. \Magefan\Blog\Helper\Config::XML_PATH_EXTENSION_ENABLED,
  57. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  58. )) {
  59. return '';
  60. }
  61. return parent::_toHtml();
  62. }
  63. }