Skip to content

Commit

Permalink
use observer
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Oct 25, 2024
1 parent 08242f7 commit 49eea29
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,13 @@ public function render(Varien_Data_Form_Element_Abstract $element)
$html = $this->_getHeaderHtml($element);

$modules = (array)Mage::getConfig()->getNode('modules')->children();
/** @var Mage_Core_Model_Config_Element $module */
foreach ($modules as $index => $module) {
$module = $module->asArray();
if ($module['active'] === 'false') {
unset($modules[$index]);
}
}

$modules = array_keys($modules);

$dispatchResult = new Varien_Object($modules);
Mage::dispatchEvent(
'adminhtml_system_config_advanced_disableoutput_render_before',
['modules' => $dispatchResult]
);
$modules = $dispatchResult->toArray();
$modules = array_keys($dispatchResult->toArray());

sort($modules);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,24 @@ public function afterCustomUrlChanged($observer)
->sendResponse();
exit(0);
}

/**
* Hide disabled modules
*
* @see Mage_Adminhtml_Block_System_Config_Form_Fieldset_Modules_DisableOutput::render()
*/
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) {
$module = $module->asArray();
if ($module['active'] === 'false') {
unset($data[$index]);
}
}
$modules->setData($data);
}
}
8 changes: 8 additions & 0 deletions app/code/core/Mage/Adminhtml/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@
</bind_locale>
</observers>
</admin_system_config_changed_section_admin>
<adminhtml_system_config_advanced_disableoutput_render_before>
<observers>
<hide_disabled>
<class>adminhtml/system_config_backend_admin_observer</class>
<method>beforeRenderModuleList</method>
</hide_disabled>
</observers>
</adminhtml_system_config_advanced_disableoutput_render_before>
</events>
<global_search>
<products>
Expand Down

0 comments on commit 49eea29

Please sign in to comment.