Changes
Title
changed
Yii registry, how to use it, idoes it exists at all?
Category
unchanged
How-tos
Yii version
unchanged
Tags
changed
Zend_Registry, registry, params, CMap, magic, get, assets, state, global, globalstate
Content
changed
[...]
return array(
'abc' =>123,
);
```
Addition 1: Yii global state
----------------------------
The params array, can be good registry for the current life cycle.
but yii also has something called "globalstate", it allow you save the data "forever"
CApplication has 3 methods:<br>
**getGlobalState**(string **$key**, mixed **$defaultValue**=NULL)<br>
**setGlobalState**(string **$key**, mixed $value, mixed **$defaultValue**=NULL)<br>
**clearGlobalState**()<br>
every thing you set via setGlobalState will be saved in runtime/global.bin in serialized form
Some common component that use it is CSecurityManager for validation key
And be careful with clearGlobalState, because it will regenerate the security key...
it may have very bad effect if you for example encrypted passwords for user without specify your own key
Links
-----
[Russian version](http://resurtm.
kzcom/registry-in-yii)