问题
I have an Attribute called 'admin_module' in myUser attributeHoler and i want to manipulate it...but i don't even get how to access the values stored there. I know how to get AttributeHolder in an action, but I don't have a clue, how to access the values in it. Any help appreciated...thanks in advance. ;)
Edit after answers:
get:
$this->getUser()->getAttributeHolder()->set('beilagenbuchung.page', 1, 'admin_module');
set:
$this->getUser()->getAttributeHolder()->get('beilagenbuchung.page', null, 'admin_module');
Regards
Nils
回答1:
Check the doc ?
And by the way, you can see all the attribute using the web debug toolbar: config > User > attributeHolder. Key is the namespace used (if you define one).
See also, the sfUser.class.php where the getter are to retrieve attributes.
回答2:
Out of any context (meaning sfAction
, sfComponent
...) you can always set attributes like this:
sfContext::getInstance()->getUser()->setAttribute('key', 'value');
来源:https://stackoverflow.com/questions/10210147/symfony-1-4-how-to-manipulate-the-attributeholder