2

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...

3
  • 1
    I am thinking perhaps I could extend it and override it or something? Commented Mar 1, 2013 at 17:05
  • ^ Thats the way to go. Extend the BaseUser Entity and introduce your own FormTypes Commented Mar 1, 2013 at 17:09
  • working on it. But I can't figure out how to override the annotations of the BaseUser... Commented Mar 1, 2013 at 17:40

1 Answer 1

10

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...

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

Comments

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.