从用户中获取所有组 - sfDoctrineGuardPlugin
在 sfDoctrineGuardPlugin 中是:
sfGuardUser:
actAs: [Timestampable]
columns:
first_name: string(255)
last_name: string(255)
//
indexes:
is_active_idx:
fields: [is_active]
relations:
Groups:
class: sfGuardGroup
local: user_id
foreign: group_id
refClass: sfGuardUserGroup
foreignAlias: Users
sfGuardGroup:
actAs: [Timestampable]
columns:
name:
type: string(255)
unique: true
description: string(1000)
relations:
Users:
class: sfGuardUser
refClass: sfGuardUserGroup
local: group_id
foreign: user_id
foreignAlias: Groups
sfGuardUserGroup:
options:
symfony:
form: false
filter: false
actAs: [Timestampable]
columns:
user_id:
type: integer
primary: true
group_id:
type: integer
primary: true
relations:
User:
class: sfGuardUser
local: user_id
onDelete: CASCADE
Group:
class: sfGuardGroup
local: group_id
onDelete: CASCADE
这是多对多的关系,我如何获取所有用户组?
- @method Doctrine_Collection
getGroups() 返回 当前记录的“组”集合
:
$this->groups = $this->getUser()->getGuardUser()->getGroups();
此返回:
Doctrine_Collection data : Array( )
我如何检查用户是否在组 TEST 中?
感谢您的帮助!
In sfDoctrineGuardPlugin is:
sfGuardUser:
actAs: [Timestampable]
columns:
first_name: string(255)
last_name: string(255)
//
indexes:
is_active_idx:
fields: [is_active]
relations:
Groups:
class: sfGuardGroup
local: user_id
foreign: group_id
refClass: sfGuardUserGroup
foreignAlias: Users
sfGuardGroup:
actAs: [Timestampable]
columns:
name:
type: string(255)
unique: true
description: string(1000)
relations:
Users:
class: sfGuardUser
refClass: sfGuardUserGroup
local: group_id
foreign: user_id
foreignAlias: Groups
sfGuardUserGroup:
options:
symfony:
form: false
filter: false
actAs: [Timestampable]
columns:
user_id:
type: integer
primary: true
group_id:
type: integer
primary: true
relations:
User:
class: sfGuardUser
local: user_id
onDelete: CASCADE
Group:
class: sfGuardGroup
local: group_id
onDelete: CASCADE
This is relation many to many and how can i get all groups of User?
- @method Doctrine_Collection
getGroups() Returns the
current record's "Groups" collection
i make:
$this->groups = $this->getUser()->getGuardUser()->getGroups();
this return:
Doctrine_Collection data : Array( )
how can i check whether the user is on group TEST?
Thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 sfGuardSecurityUser 类:https://github。 com/Garfield-fr/sfDoctrineGuardPlugin/blob/master/lib/user/sfGuardSecurityUser.class.php
See the sfGuardSecurityUser class: https://github.com/Garfield-fr/sfDoctrineGuardPlugin/blob/master/lib/user/sfGuardSecurityUser.class.php
您可以尝试使用查询来查找用户组:
you may try using a query to find groups of your user: