sfGuardUser inheritance with Doctrine [message #93414] |
Fri, 12 February 2010 12:43  |
nicech Messages: 3 Registered: February 2010 |
Junior Member |
|
|
I am currently using sfDoctrineGuardPlugin in order to manage different users defined as :
PrUser:
inheritance:
extends: sfGuardUser
type: concrete
firstname:
type: string(20)
notnull: true
name:
type: string(50)
notnull: true
PrJournalist:
inheritance:
extends: PrUser
type: concrete
columns:
company:
type: string(20)
notnull: true
PrManager:
inheritance:
extends: PrUser
type: concrete
columns:
skypeContact:
type: string(255)
notnull : true
1)
When i store PrJournalists and PrManagers in my fixtures files, Doctrine saves them in corresponding tables (everything is fine there) with unique ID in each table. First fact is IDs are not unique BETWEEN tables despite the fact that these tables inherits from sfGuardUser : we are losing the unicity of IDs in child tables.
2)
An other main issue is the use of sfGuard groups (and permissions) mechanism.
sfGuardUserGroup can link a sfGuardUser with a sfGuardGroup.
As far as we do not record any sfGuardUser, we can not establish a link between a user (an instance of PrJournalist OR PrManager) and a group.
Does sfGuardGroups allow to manage different classes of users that inherit from a same "PrUser" class ?
A different way to explain the same issue :
- in a record of sfGuardUserGroup, how can I point to a PrJournalist OR PrManager record ?
I hope that the issues are clear. If not, please tell me !
Thanks for any help.
HCM Advertisement
|
|
|
Re: sfGuardUser inheritance with Doctrine [message #101659 is a reply to message #93414 ] |
Sat, 26 June 2010 22:12  |
goudvis2000 Messages: 1 Registered: June 2010 |
Junior Member |
|
|
Hello,
I recently got myself involved in a Symfony/Doctrine/sfguard project. The sfguard plugin was configured to work with the logic user profile table by the way the documentation says it should:
http://trac.symfony-project.org/wiki/sfGuardPluginExtraDocum entation#Addingyourownyourownuser-profile-model:Customizethe sfAuthUsermodel
Now there were two database tables to each store certain parts of a user profile and the two parts were connected through a foreign key, that is, sf_guard_user:id > profile:user_id
and the profile table had an autoincrement id field itself. My thought is/was that this was wrong. Data integrity was not assured, for instance, you can easily insert two records in the profile table, each pointing to the same sf_guard_user.
At least the autoincrement of the profile table should go away, it has no use. There should only be one index id field, that should be unique and point to the sf_guard_user table. I know JPA can do this for you, but alas, it is a PHP project, not java
I found it to make much more sense to not couple the sf_guard_user table to a external profile table, but to use the inheritance a decent ORM system offers. So I changed the Profile declaration to:
Profile:
connection: doctrine
inheritance:
extends: sfGuardUser
type: column_aggregation
columns:
...
Effect was that the profile columns were added to the sf_guard_user table. Ok for now, as long as the sf_guard plugin doesn't add these columns itself in a next version. The extra properties of a user object are fetchable by
$this->getUser()->getGuardUser()->...
Since this is my first Symfony/Doctrine/sfguard project, the team I work in and myself, are wondering if this column_aggregation way of mixing Doctrine power with sfguard is a viable solution. Any thought from more experienced Symfony/Doctrine/sfguard developers?
|
|
|