This is with Symfony2 and Doctrine2. I have this in my user entity:
public function getRoles()
{
return $this->roles->toArray();
}
Yet however, it is returning:
array(object(Role))
Any ideas where I can start looking? I’ve been debugging for a while.
This is the logical behavior ; by default, Doctrine2 returns a
Collectionobject, and by callingtoArray()you transform it into an array. But your array still containsRoleobjects, that are basically not strings. Of course, you can define your own methods to get it as a string, I think basically you just have to callRole::getRole().Have a look at this article, it may help you.