Zend Framework 2 获取 Service Manager

时间:2015-01-23 18:27:24   收藏:0   阅读:233

在学习zend framework的时候很多的问题只能看源代码,为了加深自己的理解,记录下来平时用到的方法:

1在控制器里


$serviceLocator = $this->getServiceLocator();


2在Module.php里


namespace ModuleName;
                                                
use Zend\Mvc\MvcEvent;
                                                
class Module
{
    public function onBootstrap(MvcEvent $e)
    {
        $serviceLocator = $e->getApplication()->getServiceManager();
    }

}


3在控制器Plugin
$serviceLocator = $this->getController()->getServiceLocator();

原文:http://blog.csdn.net/benshuhuai/article/details/43057603

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!