在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()
我如何检查用户是否在组测试?
感谢您的帮助!
谢谢,但我使用$群组那么我: “
”我如何显示它? :) foreach和..? –@Tony Oriondo:如果您没有为您的用户设置组,getGroups方法会返回一个空数组。你确定你将组设置给你的用户吗? – turbod