Reputation: 59576
I am trying to use a factory to create a controller instance:
class AuthenticationController extends AbstractActionController
implements ControllerProviderInterface
{
private $loginLogoutService;
public function __construct($lls)
{
$this->loginLogoutService = $lls;
}
public function getControllerConfig() {
return array(
'factories' => array(
'Main\Controller\Authentication' => function(ControllerManager $cm) {
$sm = $cm->getServiceLocator();
$depA = $sm->get('LoginLogoutService');
$controller = new AuthenticationController($depA);
return $controller;
},
),
);
}
But I am getting an error message:
Warning: Missing argument 1 for Main\Controller\AuthenticationController::__construct()
Why isn't the factory used to create the controller?
Upvotes: 0
Views: 409
Reputation: 33148
getControllerConfig()
should be in your Module.php
, not in the controller itself. Everything else looks okay.
Upvotes: 1