I have simple UserInterface entity:
function getRoles()
{
return $this->roles->toArray();
}
and with many to many relation with Role Entity interface
/**
* @ORM\ManyToMany(targetEntity="Role", inversedBy="users", cascade={"persist"})
*/
protected $roles;
When I try to manage user roles with form Type
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('roles');
}
Symfony returns me an error:
Expected argument of type "Doctrine\Common\Collections\Collection", "array" given
I know the error is in the getRoles method of the entity User that returns an array but I also know getRoles is a method of the interface and must return an array!
Anyone have a good solution?