0

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();
}
0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Take attention on the underscores before construct. 3 vs 2
the issue is that I already have a __construct() function in the class and I can't assign both variables in the same __contruct()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.