Hi there, On 30 January 2014 22:32, erkinaka <erkinaka...@yahoo.com> wrote:
> i want to get a param from module.php in any model but i have the error > above. Are you really really really sure that you need that parameter into your model? Shouldn't it fit the services that manipulate the model instead? > What is the solution. i try all the solutions in form but i couldn't > solve > > my module.php > > public function getServiceConfig() > { > > return array( > 'factories' => array( > 'adapter1' => function ($sm) { > $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); > return $dbAdapter; > },..... > > my model > > namespace Sorubankam\Model; > > > use Zend\Db\Sql\Select; > use Zend\ServiceManager\ServiceLocatorAwareInterface; > use Zend\ServiceManager\ServiceLocatorInterface; > > class CustomCls implements ServiceLocatorAwareInterface > { > protected $services; > > > public function setServiceLocator(ServiceLocatorInterface > $serviceLocator) > { > $this->services = $serviceLocator; > } > > public function getServiceLocator() > { > return $this->services; > } > > public function deneme() > { > $adapter=$this->services->get("Sorubankam\Model\CustomCls"); /* > Error line */ > A model is not coming from the service manager, and if it is, then something is wrong/fishy. Only services that are created from a service manager that has an initializer for `ServiceLocatorAwareInterface` instances will inject that instance into newly spawned service instances. You can Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/