#83386Extbase FrontendUser Class creates ObjectStorage for Usergroups only in constructor
Description
The FrontendUser Class creates ObjectStorage for Usergroups only in the constructor, like this.
public function __construct($username = '', $password = '')
{
$this->username = $username;
$this->password = $password;
$this->usergroup = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
If no usergroup for the user is added upon creation of the frontenduser, it is not possible to simply add a new usergroup later. The reason is that $this->usergroup is null when fetching the frontenduser from the repository. I think this could be resolved with simply implementing an initializeObject() method in TYPO3\CMS\Extbase\Domain\Model\FrontendUser like this:
public function __construct($username = '', $password = '')
{
$this->username = $username;
$this->password = $password;
$this->initializeObject();
}
public function initializeObject()
{
$this->usergroup = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}