Action.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © 2017 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\App\Action;
  9. /**
  10. * Blog frontend action controller
  11. */
  12. abstract class Action extends \Magento\Framework\App\Action\Action
  13. {
  14. /**
  15. * Retrieve true if blog extension is enabled.
  16. *
  17. * @return bool
  18. */
  19. protected function moduleEnabled()
  20. {
  21. return (bool) $this->getConfigValue(
  22. \Magefan\Blog\Helper\Config::XML_PATH_EXTENSION_ENABLED,
  23. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  24. );
  25. }
  26. /**
  27. * Retrieve store config value
  28. *
  29. * @return string | null | bool
  30. */
  31. protected function getConfigValue($path)
  32. {
  33. $config = $this->_objectManager->get('\Magento\Framework\App\Config\ScopeConfigInterface');
  34. return $config->getValue(
  35. $path,
  36. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  37. );
  38. }
  39. /**
  40. * Throw control to cms_index_noroute action.
  41. *
  42. * @return void
  43. */
  44. protected function _forwardNoroute()
  45. {
  46. $this->_forward('index', 'noroute', 'cms');
  47. }
  48. }