I have several models:
class ModeloA {
public function __construct(){}
}
class ModeloB {
public function __construct($param1, $param2){}
}
And a controller to which I inject the models:
$controller = new Controller($modelInstance);
I need to determine which of the models I'm going to pass to the controller and for that I need a function that is able to build a ModelA or ModelB object depending on a variable, that variable would be the name of the controller ($ controllerName):
public function modelBuilder($controllerName) {
// Construir objeto ModeloA o ModeloB en funcion de $controllerName
}
// Para luego poder hacer
$controller = new $controllerName($modelInstance);