on my webproject I've been using the Hautelook Alice Bundle (https://github.com/hautelook/AliceBundle) to create my fixtures for dev and testing. For User Management I'm using the FOS UserBundle. My data file looked somewhat like this and it used to work perfectly 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 to have different login mechanisms for different user groups (staff and customers), so I want to use the Rollerworks Multi User Bundle (https://github.com/rollerworks/RollerworksMultiUserBundle).
I have created a new bundle for customers and staff and set everything up. When using the application everything works just fine. But generating the fixtures does not work anymore.
In the data file just 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 I run the fixtures command (or run the tests which also execute the generate fixtures command) it looks like it's trying to just insert the values into the database without running the FOS UserBundle constructor for the entity first, as the password, username_canonical, etc are not set.
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'INSERT INTO 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with 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 be null
I'm stuck with this for a few days now, does anyone have any suggestions?
Thanks