Widget.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Sidebar;
  9. /**
  10. * Blog sidebar widget trait
  11. */
  12. trait Widget
  13. {
  14. /**
  15. * Retrieve block sort order
  16. * @return int
  17. */
  18. public function getSortOrder()
  19. {
  20. if (!$this->hasData('sort_order')) {
  21. $this->setData('sort_order', $this->_scopeConfig->getValue(
  22. 'mfblog/sidebar/'.$this->_widgetKey.'/sort_order', \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  23. ));
  24. }
  25. return (int) $this->getData('sort_order');
  26. }
  27. /**
  28. * Retrieve block html
  29. *
  30. * @return string
  31. */
  32. protected function _toHtml()
  33. {
  34. if ($this->_scopeConfig->getValue(
  35. 'mfblog/sidebar/'.$this->_widgetKey.'/enabled', \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  36. )) {
  37. return parent::_toHtml();
  38. }
  39. return '';
  40. }
  41. }