ConfigSectionChecker.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\Controller\Adminhtml\System;
  7. use Magento\Framework\Exception\NotFoundException;
  8. /**
  9. * @deprecated 101.0.0 - unused class.
  10. * @see \Magento\Config\Model\Config\Structure\Element\Section::isAllowed()
  11. */
  12. class ConfigSectionChecker
  13. {
  14. /**
  15. * @var \Magento\Config\Model\Config\Structure
  16. */
  17. protected $_configStructure;
  18. /**
  19. * @param \Magento\Config\Model\Config\Structure $configStructure
  20. */
  21. public function __construct(\Magento\Config\Model\Config\Structure $configStructure)
  22. {
  23. $this->_configStructure = $configStructure;
  24. }
  25. /**
  26. * Check if specified section allowed in ACL
  27. *
  28. * Will forward to deniedAction(), if not allowed.
  29. *
  30. * @param string $sectionId
  31. * @throws \Exception
  32. * @return bool
  33. * @throws NotFoundException
  34. */
  35. public function isSectionAllowed($sectionId)
  36. {
  37. try {
  38. if (false == $this->_configStructure->getElement($sectionId)->isAllowed()) {
  39. throw new \Exception('');
  40. }
  41. return true;
  42. } catch (\Zend_Acl_Exception $e) {
  43. throw new NotFoundException(__('Page not found.'));
  44. } catch (\Exception $e) {
  45. return false;
  46. }
  47. }
  48. }