diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php index e7fb5cfdc1f..9ece6d7c8eb 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php @@ -28,25 +28,37 @@ public function render(Varien_Data_Form_Element_Abstract $element) { $html = $this->_getHeaderHtml($element); - $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children()); + $modules = $this->getModules(); + foreach ($modules as $moduleName) { + if ($moduleName === 'Mage_Adminhtml') { + continue; + } + $html .= $this->_getFieldHtml($element, $moduleName); + } + + return $html . $this->_getFooterHtml($element); + } + + public function getModules(): array + { + $modules = (array)Mage::getConfig()->getNode('modules')->children(); $dispatchResult = new Varien_Object($modules); Mage::dispatchEvent( - 'adminhtml_system_config_advanced_disableoutput_render_before', + 'adminhtml_system_config_advanced_disableoutput_module_config_after', ['modules' => $dispatchResult] ); - $modules = $dispatchResult->toArray(); + $modules = array_keys($dispatchResult->toArray()); sort($modules); - foreach ($modules as $moduleName) { - if ($moduleName === 'Mage_Adminhtml') { - continue; - } - $html .= $this->_getFieldHtml($element, $moduleName); - } + $dispatchResult = new Varien_Object($modules); + Mage::dispatchEvent( + 'adminhtml_system_config_advanced_disableoutput_render_before', + ['modules' => $dispatchResult] + ); - return $html . $this->_getFooterHtml($element); + return $dispatchResult->toArray(); } protected function _getDummyElement() diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Admin/Observer.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Admin/Observer.php index 303a9473232..24e61544d44 100644 --- a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Admin/Observer.php +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Admin/Observer.php @@ -46,4 +46,23 @@ public function afterCustomUrlChanged($observer) ->sendResponse(); exit(0); } + + /** + * Hide disabled modules + * + * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset_Modules_DisableOutput::getModules() + */ + public function beforeRenderModuleList(Varien_Event_Observer $observer): void + { + $event = $observer->getDataByKey('event'); + $modules = $event->getDataByKey('modules'); + $data = $modules->getData(); + /** @var Mage_Core_Model_Config_Element $module */ + foreach ($data as $index => $module) { + if ($module->active === 'false') { + unset($data[$index]); + } + } + $modules->setData($data); + } } diff --git a/app/code/core/Mage/Adminhtml/etc/config.xml b/app/code/core/Mage/Adminhtml/etc/config.xml index b56429252f4..f1a38283859 100644 --- a/app/code/core/Mage/Adminhtml/etc/config.xml +++ b/app/code/core/Mage/Adminhtml/etc/config.xml @@ -115,6 +115,14 @@ + + + + adminhtml/system_config_backend_admin_observer + beforeRenderModuleList + + + diff --git a/tests/unit/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php b/tests/unit/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php new file mode 100644 index 00000000000..74ed0b5e1f5 --- /dev/null +++ b/tests/unit/Mage/Adminhtml/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php @@ -0,0 +1,65 @@ +subject = new Mage_Adminhtml_Block_System_Config_Form_Fieldset_Modules_DisableOutput(); + } + + /** + * @group Mage_Adminhtml + * @group Mage_Adminhtml_Block + */ + public function testGetModulesCount(): void + { + $this->assertCount(60, $this->subject->getModules()); + } + + /** + * @dataProvider provideModules + * @group Mage_Adminhtml + * @group Mage_Adminhtml_Block + */ + public function testGetModules(string $module): void + { + $result = $this->subject->getModules(); + $this->assertArrayHasKey($module, array_flip($result)); + } + + public function provideModules(): Generator + { + yield 'Mage_Admin' => [ + 'Mage_Admin' + ]; + yield 'Mage_Core' => [ + 'Mage_Core' + ]; + } +}