Tabs.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * System configuration tabs block
  8. *
  9. * @method setTitle(string $title)
  10. *
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. */
  13. namespace Magento\Config\Block\System\Config;
  14. /**
  15. * @api
  16. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  17. * @since 100.0.2
  18. */
  19. class Tabs extends \Magento\Backend\Block\Widget
  20. {
  21. /**
  22. * Tabs
  23. *
  24. * @var \Magento\Config\Model\Config\Structure\Element\Iterator
  25. */
  26. protected $_tabs;
  27. /**
  28. * Block template filename
  29. *
  30. * @var string
  31. */
  32. protected $_template = 'Magento_Config::system/config/tabs.phtml';
  33. /**
  34. * Currently selected section id
  35. *
  36. * @var string
  37. */
  38. protected $_currentSectionId;
  39. /**
  40. * Current website code
  41. *
  42. * @var string
  43. */
  44. protected $_websiteCode;
  45. /**
  46. * Current store code
  47. *
  48. * @var string
  49. */
  50. protected $_storeCode;
  51. /**
  52. * @var \Magento\Backend\Helper\Data
  53. */
  54. protected $_backendHelper;
  55. /**
  56. * @param \Magento\Backend\Block\Template\Context $context
  57. * @param \Magento\Config\Model\Config\Structure $configStructure
  58. * @param \Magento\Backend\Helper\Data $backendHelper
  59. * @param array $data
  60. */
  61. public function __construct(
  62. \Magento\Backend\Block\Template\Context $context,
  63. \Magento\Config\Model\Config\Structure $configStructure,
  64. \Magento\Backend\Helper\Data $backendHelper,
  65. array $data = []
  66. ) {
  67. $this->_backendHelper = $backendHelper;
  68. parent::__construct($context, $data);
  69. $this->_tabs = $configStructure->getTabs();
  70. $this->setId('system_config_tabs');
  71. $this->setTitle(__('Configuration'));
  72. $this->_currentSectionId = $this->getRequest()->getParam('section');
  73. $this->_backendHelper->addPageHelpUrl($this->getRequest()->getParam('section') . '/');
  74. }
  75. /**
  76. * Get all tabs
  77. *
  78. * @return \Magento\Config\Model\Config\Structure\Element\Iterator
  79. */
  80. public function getTabs()
  81. {
  82. return $this->_tabs;
  83. }
  84. /**
  85. * Retrieve section url by section id
  86. *
  87. * @param \Magento\Config\Model\Config\Structure\Element\Section $section
  88. * @return string
  89. */
  90. public function getSectionUrl(\Magento\Config\Model\Config\Structure\Element\Section $section)
  91. {
  92. return $this->getUrl('*/*/*', ['_current' => true, 'section' => $section->getId()]);
  93. }
  94. /**
  95. * Check whether section should be displayed as active
  96. *
  97. * @param \Magento\Config\Model\Config\Structure\Element\Section $section
  98. * @return bool
  99. */
  100. public function isSectionActive(\Magento\Config\Model\Config\Structure\Element\Section $section)
  101. {
  102. return $section->getId() == $this->_currentSectionId;
  103. }
  104. }