I send variables to my route via an ajax post. Based on the value of my type
value I create a new Object, like this:
if($request->get('type') === 'HardwareType'){
$e = new HardwareType();
}else if($request->get('type') === 'SetupType'){
$e => new SetupType();
}else{
new NotFoundHttpException();
}
This gets out of hand quickly even with a switch
I think its still "ugly". Is there any way I could do sth. like this:
$e = new $request->get('type')();
Any hint appreciated
EDIT I use the class(es) with this use AppBundle\Entity\HardwareType;
etc.