Hi,
I have enabled Usergroups in my setup and now I get an error message when I call fos:user:create from the command line:
[ErrorException]
Warning: in_array() expects parameter 2 to be array, null given in [...]/Symfony/vendor/bundles/FOS/UserBundle/Model/User.php line 160
It asks for username, email and password, and this message comes after that.
Some idea why?
Does your user class call the parent constructor when overwriting it ?
Sorry for the late reply, I had to work on another project...
Yes, these are the first lines of my code:
<?php
namespace oko\Bundle\SecurityBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* oko\Bundle\SecurityBundle\Entity\User
*/
class User extends BaseUser
{
The code you pasted does not contain the constructor
public function __construct()
{
$this->groups = new \Doctrine\Common\Collections\ArrayCollection();
}
the issue is indeed there: you are not calling the parent constructor and so the object is not initialized properly.
ah, thanks! that was the problem!
I had the same issue, here I add the way to call the parent to help future users.
public function __construct()
{
parent::__construct ();
}
Most helpful comment
I had the same issue, here I add the way to call the parent to help future users.