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 da8829fd498..7c2dcc3ca1a 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 @@ -27,17 +27,7 @@ public function render(Varien_Data_Form_Element_Abstract $element) { $html = $this->_getHeaderHtml($element); - $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children()); - - $dispatchResult = new Varien_Object($modules); - Mage::dispatchEvent( - 'adminhtml_system_config_advanced_disableoutput_render_before', - ['modules' => $dispatchResult] - ); - $modules = $dispatchResult->toArray(); - - sort($modules); - + $modules = $this->getModules(); foreach ($modules as $moduleName) { if ($moduleName === 'Mage_Adminhtml') { continue; @@ -49,6 +39,28 @@ public function render(Varien_Data_Form_Element_Abstract $element) return $html; } + public function getModules(): array + { + $modules = (array)Mage::getConfig()->getNode('modules')->children(); + + $dispatchResult = new Varien_Object($modules); + Mage::dispatchEvent( + 'adminhtml_system_config_advanced_disableoutput_module_config_after', + ['modules' => $dispatchResult] + ); + + $modules = array_keys($dispatchResult->toArray()); + sort($modules); + + $dispatchResult = new Varien_Object($modules); + Mage::dispatchEvent( + 'adminhtml_system_config_advanced_disableoutput_render_before', + ['modules' => $dispatchResult] + ); + + return $dispatchResult->toArray(); + } + protected function _getDummyElement() { if (empty($this->_dummyElement)) { 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 f0f83b0de9f..39d40d0be7c 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 @@ -45,4 +45,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..05cf7aa8bc6 --- /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->assertSame(60, count($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' + ]; + } +}