Zend_Registry
Using global variables is generally considered unwise for large applications as it introduces coupling
between modules and it is very difficult to track down where and when a given global variable is modified
during the processing of a script. The solution is to pass variables as parameters through functions to where the
data is required. However, this causes a problem in that you can end up with lots of ???pass-through??? parameters
which clutter up function signatures for functions that do not use the data, except to pass it on to the next
function.
One solution to this is to consolidate the storage of such data into a single object which is easy to find; this
is known as the registry. As its name implies, Zend_Registry implements the Registry design pattern and so is
a handy place to store objects that are required in different parts of the application.
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
Zend_Registry::set() is used to register to objects with the registry. Internally, the registry is implemented
as an associative array and so when you register an object with it, you have to supply the key name that you
want to identify it with.
Pages:
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95