servicemanager

how to create a factory in zend framework 2?

非 Y 不嫁゛ 提交于 2020-01-21 04:47:08
问题 in my Module.php i have the fallowing methods that i would like to move them in a factory class so that i wont clutter the Module class : public function getControllerConfig() { return array( 'factories' => array( 'account-index' => function ($controllerManager) { $serviceManager = $controllerManager->getServiceLocator(); $accountService = $serviceManager->get('account-service'); return new Controller\IndexController($accountService); } ) ); } public function getServiceConfig() { return array

zf2 ServiceManager vs ServiceLocator

蓝咒 提交于 2019-12-12 10:29:05
问题 I am learning zf2, reading docs, tutorials etc from the web. Now I am confused regarding Zend\ServiceManager\ServiceManagerAwareInterface.php and Zend\ServiceManager\ServiceLocatorAwareInterface.php . Also in some place (like controller) I use $this->getServiceLocator() to fetch the ServiceManager object while at some other places we use ->getServiceManager() and it also returns the same ServiceManager object. 回答1: The Locator is the interface. The design of Zend Framework 2 is done with

Use another module in our custom helper in zend framework 2

為{幸葍}努か 提交于 2019-12-07 18:29:39
问题 I want to use WebinoImageThumb moudle in my custom helper , but when I want to create an instance of this module in helper factories I got this error : Zend\View\HelperPluginManager::get was unable to fetch or create an instance for WebinoImageThumb But I can access to an instance in my controller without any problem. This is the code I get error in : public function getViewHelperConfig() { return array( 'factories' => array( 'ImageLib' => function ($sm) { $WebinoImageThumb = $sm->get(

Use another module in our custom helper in zend framework 2

狂风中的少年 提交于 2019-12-06 11:59:44
I want to use WebinoImageThumb moudle in my custom helper , but when I want to create an instance of this module in helper factories I got this error : Zend\View\HelperPluginManager::get was unable to fetch or create an instance for WebinoImageThumb But I can access to an instance in my controller without any problem. This is the code I get error in : public function getViewHelperConfig() { return array( 'factories' => array( 'ImageLib' => function ($sm) { $WebinoImageThumb = $sm->get('WebinoImageThumb'); return new \Base\view\helper\ImageLib($WebinoImageThumb); } ) ); } The question that's

ZF2 load service config from module

爱⌒轻易说出口 提交于 2019-12-02 15:19:36
问题 I am still struggling in instantiating a service from a ZF2 module outside of Zend Framework (in a blank .php). I want to achieve: Instantiate + invoke a ZF2 service method from outside ZF by the use of the ServiceManager and possibly DI. What I have now: ( UPDATED 4/10/2013 ) Following up on the comments below I have done more research,particularly: The quick guide http://framework.zend.com/manual/2.0/en/modules/zend.service-manager.quick-start.html RTD (Databases and models) http: //zf2

ZF2 load service config from module

本小妞迷上赌 提交于 2019-12-02 09:25:21
I am still struggling in instantiating a service from a ZF2 module outside of Zend Framework (in a blank .php). I want to achieve: Instantiate + invoke a ZF2 service method from outside ZF by the use of the ServiceManager and possibly DI. What I have now: ( UPDATED 4/10/2013 ) Following up on the comments below I have done more research,particularly: The quick guide http://framework.zend.com/manual/2.0/en/modules/zend.service-manager.quick-start.html RTD (Databases and models) http: //zf2.readthedocs.org/en/latest/user-guide/database-and-models.html Modules presentation (Very helpful) http:/

how to create a factory in zend framework 2?

落花浮王杯 提交于 2019-11-30 19:48:32
in my Module.php i have the fallowing methods that i would like to move them in a factory class so that i wont clutter the Module class : public function getControllerConfig() { return array( 'factories' => array( 'account-index' => function ($controllerManager) { $serviceManager = $controllerManager->getServiceLocator(); $accountService = $serviceManager->get('account-service'); return new Controller\IndexController($accountService); } ) ); } public function getServiceConfig() { return array( 'factories' => array( 'account-service' => function ($serviceManages) { return new Service\Account; }