Skip to content

Property "roles" in "UserBundle\Entity\User" was already declared, but it must be declared only once #1137

@oste

Description

@oste

During a recent update I started getting this error. If I revert back to "friendsofsymfony/user-bundle": "dev-master#2c3b05b52c96b91255afc6d0d03dd97b03d17c4d" things work as before.

Here is a quick outline of what I am doing.

I have my UserClass that looks like this

<?php
namespace UserBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

use UserBundle\Entity\Role;

/**
 * @ORM\Table(name="users")
 * @ORM\Entity()
 */
class User extends BaseUser
{

    /**
    * @ORM\ManyToMany(targetEntity="UserBundle\Entity\Role")
    * @ORM\JoinTable(name="users_roles_rel")
    */
    protected $roles;

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

So I am re-declaring the roles property, but I am extending it to be a many to many relationship. Should I be doing this in a new way to adhere to the recent changes to the bundle?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions