【发布时间】:2016-03-07 06:23:42
【问题描述】:
在我的网络项目中,我一直在使用 Hautelook Alice Bundle (https://github.com/hautelook/AliceBundle) 来创建用于开发和测试的装置。对于用户管理,我使用 FOS UserBundle。 我的数据文件看起来有点像这样,它曾经工作得非常好:
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()>
现在我正在尝试为不同的用户组(员工和客户)设置不同的登录机制,所以我想使用 Rollerworks 多用户捆绑包 (https://github.com/rollerworks/RollerworksMultiUserBundle)。
我为客户和员工创建了一个新捆绑包并设置了所有内容。使用该应用程序时,一切正常。但是生成固定装置不再起作用。
在数据文件中只是命名空间发生了变化。
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()>
当我运行 fixtures 命令(或运行同时执行 generate fixtures 命令的测试)时,它看起来只是试图将值插入数据库而不首先运行实体的 FOS UserBundle 构造函数,作为密码,未设置 username_canonical 等。
[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
我这几天都被这个问题困住了,有人有什么建议吗?
谢谢
【问题讨论】:
标签: php symfony fosuserbundle