php - Symfony2 using Multiuser Bundle and Alice Bundle -
on webproject i've been using hautelook alice bundle (https://github.com/hautelook/alicebundle) create fixtures dev , testing. user management i'm using fos userbundle. data file looked , used work fine:
appbundle\entity\staffdetail: staffdetail_{1..5}: prefix: <title()> first_name: <firstname()> last_name: <lastname()> appbundle\entity\staff: staff_1: username: admin@example.com plainpassword: password email: admin@example.com mandant: @mandant_1 enabled: true role: administrator staffdetail: @staffdetail_1 staff_{2..5}: username (unique): <safeemail()> plainpassword: password email: <identity($username)> mandant: @mandant_1 enabled: true role: administrator staffdetail: @staffdetail_<current()> now i'm trying have different login mechanisms different user groups (staff , customers), want use rollerworks multi user bundle (https://github.com/rollerworks/rollerworksmultiuserbundle).
i have created new bundle customers , staff , set up. when using application works fine. generating fixtures not work anymore.
in data file namespaces changed.
users\staffbundle\entity\staffdetail: staffdetail_{1..5}: prefix: <title()> first_name: <firstname()> last_name: <lastname()> users\staffbundle\entity\staff: staff_1: username: admin@example.com plainpassword: password email: admin@example.com mandant: @mandant_1 enabled: true role: administrator staffdetail: @staffdetail_1 staff_{2..5}: username (unique): <safeemail()> plainpassword: password email: <identity($username)> mandant: @mandant_1 enabled: true role: administrator staffdetail: @staffdetail_<current()> when run fixtures command (or run tests execute generate fixtures command) looks it's trying insert values database without running fos userbundle constructor entity first, password, username_canonical, etc not set.
[doctrine\dbal\dbalexception] exception occurred while executing 'insert staff (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_tok en, password_requested_at, roles, credentials_expired, credentials_expire_at, role, staffdetail_id, mandant_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' params ["ad min@example.com", null, "admin@example.com", null, 1, "kbttb26978gkkcosk404wccgc4os8wo", null, null, 0, 0, null, null, null, "a:0:{}", 0, null, "administrator", 22, 13]: sqlstate[23000]: integrity constraint violation: 1048 column 'username_canonical' cannot null i'm stuck few days now, have suggestions?
thanks
add usernamecanonical fixture:
users\staffbundle\entity\staff: staff_1: usernamecanonical: <identity($username)> this same other staff entries. user have logic fills automatically based on username value.
make sure users\staffbundle\entity\staff implements fos\userbundle\model\userinterface , fos\userbundle\doctrine\userlistener called (it call updatecanonicalfields , updatepassword before saving user).
read more here: http://symfony.com/doc/current/bundles/fosuserbundle/user_manager.html#updating-a-user-object
Comments
Post a Comment