简体   繁体   English

Zend框架。 如何检查特定的Front Controller插件是否已注册?

[英]Zend Framework. How to check if specific Front Controller Plugin is registered?

I currently do it this way (to check if Layout Front Controller plugin has been registered for example): 我目前以这种方式执行此操作(例如检查Layout Front Controller插件是否已注册):

$front = Zend_Controller_Front::getInstance();
if($front->hasPlugin('Zend_Layout_Controller_Plugin_Layout')){
//....do something
};

IS this a good way? 这是个好方法吗? are there any other ways to check it? 还有其他检查方法吗?

You already ask the front controller if it has the plugin registered, I think this is straight enough and there is nothing wrong with this. 您已经问过前端控制器是否已注册了插件,我认为这很简单,而且没有错。 You could just make it a little shorter: 您可以将其缩短一点:

if (Zend_Controller_Front::getInstance()->hasPlugin('Zend_Layout_Controller_Plugin_Layout')) {
    //....do something
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM