2
votes

As I am creating a web application that will be used in research on patients in the health domain, I want all my users to be completely anonymous. Can I in a simple way get rid of the email and email_canonical fields without rewriting stuff in the bundle itself, for instance by doing something to my User Class in my own bundle?

EDIT: I did this:

/**

*   @ORM\Column(nullable=true)

**/

protected $email;



/**

*   @ORM\Column(nullable=true)

**/

protected $emailCanonical; 

In my User entity class. Bu twhen I do php app/console doctrine:schema:update --force i get

[Doctrine\ORM\Mapping\MappingException]
Duplicate definition of column 'email' on entity 'Pan100\MoodLogBundle\Enti
ty\User' in a field or discriminator column mapping.

EDIT 2: Forgot to say this is done in a class extending the FOUserBundle's model class User as BaseUser...

1
I am thinking perhaps I could extend it and override it or something?Piddien
^ Thats the way to go. Extend the BaseUser Entity and introduce your own FormTypesmblaettermann
working on it. But I can't figure out how to override the annotations of the BaseUser...Piddien

1 Answers

10
votes

OK!

I did:

...
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
* @ORM\AttributeOverrides({
*              @ORM\AttributeOverride(name="email", column=@ORM\Column(nullable=true)),
*              @ORM\AttributeOverride(name="emailCanonical", column=@ORM\Column(nullable=true, unique=false))
*  
* })  
*/

class User extends BaseUser
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */

    protected $id;
...(code emitted)

Later I will find out if more is needed - I will probably have to override some of the FOSUserBundle methods for creating users. At least the "php app/console fos:user:create testuser" command requires an email... But it does not have to be unique anymore, so if I am hindered later I can just add the string "none" or something...