I'm using sfDoctrineGuardPlugin
to manage users, groups and authentication in my Symfony application.
Now I would like to add an avatar to the sfGuardUser
model. How can I do that? What's the best approach? I have seen several ways on the Internet, but I do not want to mess my code up.
Thanks!
There are two ways.
The second one is the most recommended specially if you are planing to have a lot of information inside your user model. But if you have only an avatar field to add, extending sfGuardUser is more convenient.
To do so, put the new sfGuardUser.schema.yml inside your /config/ folder. It will be used instead of the plugin one's.
To create a "Profile" there is nothing particular to know about:
Profile:
tableName: profile
columns:
sf_guard_user_id: integer
firstname: varchar(100)
phone: varchar(15)
relations:
sfGuardUser: { class: sfGuardUser, onDelete: CASCADE, local: sf_guard_user_id, foreign: id, foreignType: one }