php 确定是否启用了 Magento 模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3551846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Determine if Magento module is enabled
提问by Colin O'Dell
What is the best way to determine if a particular module is enabled/active in Magento? I've tried using class_exists
to check if my code has been loaded and parsed by PHP but lately I've noticed its pretty unreliable (returns true
even when I delete the module's .xml configuration).
确定特定模块是否在 Magento 中启用/活动的最佳方法是什么?我尝试使用class_exists
来检查我的代码是否已被 PHP 加载和解析,但最近我注意到它非常不可靠(true
即使我删除了模块的 .xml 配置也会返回)。
Is there a core function I can call?
有我可以调用的核心功能吗?
回答by datenbrille
If you would like to use a build in function just use
如果您想使用内置功能,只需使用
Mage::helper('core')->isModuleEnabled(<module name>);
It is implemented in
它实施于
Mage_Core_Helper_Abstract
回答by Jonathan Day
Here's another option that is a more elegant way of finding out the status:
这是另一种更优雅的查找状态的方法:
Mage::getConfig()->getModuleConfig('modulename')->is('active', 'true')