FOSUserBundle
FOSUserBundle copied to clipboard
Strange behavior while adding __clone function in User class
Is it possible to use the __clone function inside de User class? Each time I implement this class I get really strange beahavior... The app always return to the login check route!
I've also just encountered this. Very strange. If anyone has an answer as to why this is, it'd be good to know!
I only needed to nullify a couple of properties in my entity on clone so I've been able to do this in the controller after cloning the entity object but admittedly it would be nicer to have these in __clone()
$obj = new Obj();
$obj2 = clone $obj;
$obj2->setId(null);
In fact, I've just found this; http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/architecture.html#entities
This seems to suggest that using __clone() in entities is really a no no unless you safely implement the method. However, even using the example there and only running when the check for an ID passes seems to log me back out...