[symfony-users] Re: sfDoctrineGuard user profile one-to-one relationships
Customizing the plugin schema. Perfect. Thanks! On Oct 25, 6:08 am, Massimiliano Arione garak...@gmail.com wrote: On 23 Ott, 01:31,Jonotronjonot...@gmail.com wrote: I want to create a one-to-one relationship between users and companies. Since I shouldn't be editing the sfDoctrineGuard schema's directlyI've created a sfGuardUserProfile model: You can override plugin's schema without editing it: http://www.symfony-project.org/gentle-introduction/1_4/en/17-Extendin... cheers Massimiliano -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: sfDoctrineGuard user profile one-to-one relationships
On 23 Ott, 01:31, Jonotron jonot...@gmail.com wrote: I want to create a one-to-one relationship between users and companies. Since I shouldn't be editing the sfDoctrineGuard schema's directlyI've created a sfGuardUserProfile model: You can override plugin's schema without editing it: http://www.symfony-project.org/gentle-introduction/1_4/en/17-Extending-Symfony#chapter_17_sub_doctrine cheers Massimiliano -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: sfDoctrineGuard user profile one-to-one relationships
You can extend user model with your own attributes to this model in your own schema.yml file. You can even overwrite user's native fields definition in that matter. It's completely valid. And refClass will always produce Collection as it' the many-to-many relation definition. If it's not satisfying you, there's always Doctrine Inheritance ;) On 23 Paź, 03:01, Jonotron jonot...@gmail.com wrote: I guess one-to-one in this case isn't the correct description. sfGuardUser has one Company, Company has man sfGuardUser. To accomplish this (because I shouldn't edit the sfGuardUser model directly) I go through an intermediary table sfGuardUserProfile. I believe my schema above is correct, and the refClass is generated because I am using the intermediary table and I can't eliminated it as it is in the base model. On Oct 22, 4:50 pm, Stéphane stephane.er...@gmail.com wrote: Hi, You don't need refClass for 1-to-1 ! Cheers, Before Printing, Think about Your Environmental Responsibility! Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale! On Sat, Oct 23, 2010 at 1:31 AM, Jonotron jonot...@gmail.com wrote: I want to create a one-to-one relationship between users and companies. Since I shouldn't be editing the sfDoctrineGuard schema's directlyI've created a sfGuardUserProfile model: sfGuardUserProfile: tableName: sf_guard_user_profile columns: user_id: { type: integer, notnull: true } org_id: { type: integer, notnull: true } relations: sfGuardUser: { onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Profile, foreignType: one, type: one } Company: { onDelete: CASCADE, local: org_id, foreign: id, foreignAlias: sfGuardUserProfiles } And my Company model has a relation like this: relations: sfGuardUser: foreignAlias: Company class: sfGuardUser local: id foreign: org_id refClass: sfGuardUserProfile foreignType: one This appears to create all the correct models, the basesfGuardUser model has: $this-hasOne('Company', array( 'refClass' = 'sfGuardUserProfile', 'local' = 'org_id', 'foreign' = 'id')); However, when I do: $sf_user-getGuardUser()-getCompany(); it returns a collection rather than an object. The simple fix is to do this: $sf_user-getGuardUser()-getProfile()-getCompany(); (and refactor it into the sfGuardUser class) I suspect that the refClass is what is causing this behaviour. Is this intended? is there another way to create a one-to-one relationship as I've described above? My solution works, but it feels wrong somehow. Thanks -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: sfDoctrineGuard user profile one-to-one relationships
I guess one-to-one in this case isn't the correct description. sfGuardUser has one Company, Company has man sfGuardUser. To accomplish this (because I shouldn't edit the sfGuardUser model directly) I go through an intermediary table sfGuardUserProfile. I believe my schema above is correct, and the refClass is generated because I am using the intermediary table and I can't eliminated it as it is in the base model. On Oct 22, 4:50 pm, Stéphane stephane.er...@gmail.com wrote: Hi, You don't need refClass for 1-to-1 ! Cheers, Before Printing, Think about Your Environmental Responsibility! Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale! On Sat, Oct 23, 2010 at 1:31 AM, Jonotron jonot...@gmail.com wrote: I want to create a one-to-one relationship between users and companies. Since I shouldn't be editing the sfDoctrineGuard schema's directlyI've created a sfGuardUserProfile model: sfGuardUserProfile: tableName: sf_guard_user_profile columns: user_id: { type: integer, notnull: true } org_id: { type: integer, notnull: true } relations: sfGuardUser: { onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Profile, foreignType: one, type: one } Company: { onDelete: CASCADE, local: org_id, foreign: id, foreignAlias: sfGuardUserProfiles } And my Company model has a relation like this: relations: sfGuardUser: foreignAlias: Company class: sfGuardUser local: id foreign: org_id refClass: sfGuardUserProfile foreignType: one This appears to create all the correct models, the basesfGuardUser model has: $this-hasOne('Company', array( 'refClass' = 'sfGuardUserProfile', 'local' = 'org_id', 'foreign' = 'id')); However, when I do: $sf_user-getGuardUser()-getCompany(); it returns a collection rather than an object. The simple fix is to do this: $sf_user-getGuardUser()-getProfile()-getCompany(); (and refactor it into the sfGuardUser class) I suspect that the refClass is what is causing this behaviour. Is this intended? is there another way to create a one-to-one relationship as I've described above? My solution works, but it feels wrong somehow. Thanks -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en