Section.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\Model\Config\Structure\Element;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class Section extends AbstractComposite
  12. {
  13. /**
  14. * Authorization service
  15. *
  16. * @var \Magento\Framework\AuthorizationInterface
  17. */
  18. protected $_authorization;
  19. /**
  20. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  21. * @param \Magento\Framework\Module\Manager $moduleManager
  22. * @param Iterator $childrenIterator
  23. * @param \Magento\Framework\AuthorizationInterface $authorization
  24. */
  25. public function __construct(
  26. \Magento\Store\Model\StoreManagerInterface $storeManager,
  27. \Magento\Framework\Module\Manager $moduleManager,
  28. Iterator $childrenIterator,
  29. \Magento\Framework\AuthorizationInterface $authorization
  30. ) {
  31. parent::__construct($storeManager, $moduleManager, $childrenIterator);
  32. $this->_authorization = $authorization;
  33. }
  34. /**
  35. * Retrieve section header css
  36. *
  37. * @return string
  38. */
  39. public function getHeaderCss()
  40. {
  41. return isset($this->_data['header_css']) ? $this->_data['header_css'] : '';
  42. }
  43. /**
  44. * Check whether section is allowed for current user
  45. *
  46. * @return bool
  47. */
  48. public function isAllowed()
  49. {
  50. return isset($this->_data['resource']) ? $this->_authorization->isAllowed($this->_data['resource']) : false;
  51. }
  52. /**
  53. * Check whether element should be displayed
  54. *
  55. * @return bool
  56. */
  57. public function isVisible()
  58. {
  59. if (!$this->isAllowed()) {
  60. return false;
  61. }
  62. return parent::isVisible();
  63. }
  64. }