sfDoctrineGuard - 如何始终将 sfGuardProfile 加入 sfGuardUser
我想让数据库随时查询sfGuardUserProfile
,它会自动加入并与其相关的sfGuardUser
结合。
如果我使用 Propel 1.2,我通常会重写 sfGuardUserProfilePeer 类的 doSelectStmt 方法来检查 Criteria 并根据需要进行修改修改 sfGuardUserProfile
类的 enchanted
方法。但我不确定如何在教义中做到这一点。
I want to make it so that anytime the db is queried for an sfGuardUserProfile
it is autmoatically joined and hydrated with its related sfGuardUser
.
If i was using Propel 1.2 i would normally override the doSelectStmt
method of the sfGuardUserProfilePeer
class to inspect the Criteria
and modify it as necessary as well as modifying the hydrate
method of the sfGuardUserProfile
class. Im not sure how to go about doing this in Doctrine though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用事件监听器。在学说文档中阅读有关它们的更多信息:事件监听器
在 symfony 1.4 中 sfGuardUser 可以修改。默认情况下位于 lib/model/doctrine/sfDoctrineGuardPLugin/sfGuardUser.class.php 中。您可以添加以下 preDqlSelect() 方法来修改查询。请注意,它尚未经过测试。
要使其正常工作,您需要打开 DQL 回调。您可以在 ProjectConfiguration 类中执行此操作:
You could use Event Listeners. Read more about them in the doctrine documentation: Event Listeners
In symfony 1.4 sfGuardUser can be modified. It's by default in lib/model/doctrine/sfDoctrineGuardPLugin/sfGuardUser.class.php. You can add following preDqlSelect() method to modify the query. Note that it's not tested.
To make it working you need to have DQL callbacks turned on. You can do it in your ProjectConfiguration class:
虽然我同意 Coronatus,但我认为您想要做的事情可以通过以下方式实现:
http: //www.symfony-project.org/plugins/sfGuardPlugin
请参阅“自定义 sfGuardUser 模型”。
基本上,配置文件需要称为“sf_guard_user_profile”并设置关系,然后您应该能够使用:
我认为某些配置文件目的需要正确的配置文件模型名称,但我可能是错的。
Although I agree with Coronatus, I think what you're looking to do can be achieved with:
http://www.symfony-project.org/plugins/sfGuardPlugin
See "Customize the sfGuardUser model".
Basically, the profile needs to be called "sf_guard_user_profile" and the relation set up, and then you should be able to use:
I think the right profile model name is needed for some config file purposes but I may be wrong.