StoreCheck.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Store\App\Action\Plugin;
  8. class StoreCheck
  9. {
  10. /**
  11. * @var \Magento\Store\Model\StoreManagerInterface
  12. */
  13. protected $_storeManager;
  14. /**
  15. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  16. */
  17. public function __construct(
  18. \Magento\Store\Model\StoreManagerInterface $storeManager
  19. ) {
  20. $this->_storeManager = $storeManager;
  21. }
  22. /**
  23. * @param \Magento\Framework\App\Action\AbstractAction $subject
  24. * @param \Magento\Framework\App\RequestInterface $request
  25. * @return void
  26. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  27. * @throws \Magento\Framework\Exception\State\InitException
  28. */
  29. public function beforeDispatch(
  30. \Magento\Framework\App\Action\AbstractAction $subject,
  31. \Magento\Framework\App\RequestInterface $request
  32. ) {
  33. if (!$this->_storeManager->getStore()->isActive()) {
  34. throw new \Magento\Framework\Exception\State\InitException(
  35. __('Current store is not active.')
  36. );
  37. }
  38. }
  39. }