Symfony 1.4: How to manipulate the attributeHolder?

China☆狼群 提交于 2019-12-11 05:12:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!