You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
I have two questions. First when did getServiceLocator start triggering a dependency injection error. Second where can I find documentation how to correctly inject dependencies into controllers. Normally I register them using Modules.php:
public function getServiceConfig()
{
return array(
'factories' => array(
'Application\Model\User' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new User());
return new TableGateway('user', $dbAdapter, null, $resultSetPrototype);
},
'Application\Model\UserTable' => function ($sm) {
$tableGateway = $sm->get('Application\Model\User');
$table = new UserTable($tableGateway);
return $table;
}
)
);
}
UserController.php
protected $userTable;
public function getUserTable()
{
if (!$this->userTable) {
$sm = $this->getServiceLocator();
$this->userTable = $sm->get('Application\Model\UserTable');
}
return $this->userTable;
}
This is a massive compatibility change and major difference how the original ZF2 documentation explained how thing worked and will have H/Yuge ramifications on production systems for existing clients. I'm currently working on an Apigility application when I noticed the change this morning. I'm afraid to look at our other ZF2 clients production systems and will warn them not to run compser update until a viable solution is tested.
The text was updated successfully, but these errors were encountered:
I have two questions. First when did getServiceLocator start triggering a dependency injection error. Second where can I find documentation how to correctly inject dependencies into controllers. Normally I register them using Modules.php:
UserController.php
This is a massive compatibility change and major difference how the original ZF2 documentation explained how thing worked and will have H/Yuge ramifications on production systems for existing clients. I'm currently working on an Apigility application when I noticed the change this morning. I'm afraid to look at our other ZF2 clients production systems and will warn them not to run compser update until a viable solution is tested.
The text was updated successfully, but these errors were encountered: