简体   繁体   中英

Symfony 1.4: How to manipulate the attributeHolder?

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

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.

在任何上下文之外( 意味着sfActionsfComponent ... ),您始终可以像这样设置属性:

sfContext::getInstance()->getUser()->setAttribute('key', 'value');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM