I'm new in ZendFramework3 and I just want to know if it's possible to call a function with more arguments than just the serviceManager in factories (within my Module class) : (Is it possible to pass an argument next to the $sm
argument?)
//class Module
//getConfig()
//getServiceConfig()
public function getControllerConfig()
{
return [
'factories' => [
Controller\ModuleController::class => function ($sm) {
return new ModuleController($sm);
}
]
];
}
If you want to create one "magical" factory for all dependencies, you should take a look at SM AbstractFactory.
In that one factory you can check from the $requestedName what will be dependencies. For eg. you can read dependencies from class constructor and than inject that dependencies (or pull it again from $container). You can also set your dependencies in config, and in that way create only one factory for all your classes.