Where and how to set variable value that is available in all controllers. I don’t wont to use zend registry and don’t want to extend Zend_Controller_Action. Is there is another way? I just want for example to set:
$a = "test";
and in Index controller to dump it:
class IndexController extends Zend_Controller_Action {
public function indexAction(){
var_dump($a);
}
}
Global vars ruin the purpose of object oriented programming… use namespace or custom configs.
Solution 1
Use session Zend_Session_Namespace, here is documentation on how to Zend_Session_Namespace.
Solution 2
Alternatively, you can create some new class with static properties and use it’s setters/getters to set and retrieve values.
E.g.