user2628204
user2628204

Reputation: 1

roles toArray() issue on symfony2

I'm following the symofny documentation to creating the login system but when I try to create a a form to create a new user I get this error, I've been looking for a solution for nothing seems to work.

FatalErrorException: Error: Call to a member function toArray() on a non-object in var/www/Frigorifico/src/Frigorifico/FrigorificoBundle/Entity/Users.php line 90

private $roles;

public function ___construct()
{
    $this->roles = new ArrayCollection();
}

 public function getRoles()
{
    return $this->roles->toArray();
}

Upvotes: 0

Views: 479

Answers (1)

falinsky
falinsky

Reputation: 7428

you should not use:

public function ___construct()
{
    $this->roles = new ArrayCollection();
}

but:

public function __construct()
{
    $this->roles = new ArrayCollection();
}

see more at official php documenation

Upvotes: 1

Related Questions