| | 145 | <para> |
|---|
| | 146 | There exists two methods to access a key. You can either get it directly get |
|---|
| | 147 | it from its parent or get as an object property through magic methods. |
|---|
| | 148 | </para> |
|---|
| | 149 | |
|---|
| | 150 | <sect5> |
|---|
| | 151 | <title>Parent key subkeys access</title> |
|---|
| | 152 | <para> |
|---|
| | 153 | To access a subkey with its parent's object, you have to use the following |
|---|
| | 154 | method. |
|---|
| | 155 | </para> |
|---|
| | 156 | |
|---|
| | 157 | <para> |
|---|
| | 158 | <methodsynopsis> |
|---|
| | 159 | <classname>Jaws_Registry_Key</classname><methodname>Jaws::getSubkey</methodname> |
|---|
| | 160 | <methodparam><type>string</type><parameter>$name</parameter></methodparam> |
|---|
| | 161 | </methodsynopsis> |
|---|
| | 162 | </para> |
|---|
| | 163 | |
|---|
| | 164 | <para> |
|---|
| | 165 | <variablelist> |
|---|
| | 166 | <varlistentry> |
|---|
| | 167 | <term><parameter>$name</parameter></term> |
|---|
| | 168 | <listitem>The name of the subkey to access</listitem> |
|---|
| | 169 | </varlistentry> |
|---|
| | 170 | </variablelist> |
|---|
| | 171 | </para> |
|---|
| | 172 | </sect5> |
|---|
| | 173 | |
|---|
| | 174 | <sect5> |
|---|
| | 175 | <title>Magic methods</title> |
|---|
| | 176 | |
|---|
| | 177 | <para> |
|---|
| | 178 | The <classname>Jaws_Registry_Key</classname> class implements magic methods |
|---|
| | 179 | that make it possible to access a registry key as a class property of its |
|---|
| | 180 | parent. This makes the following syntax valid: |
|---|
| | 181 | </para> |
|---|
| | 182 | |
|---|
| | 183 | <para> |
|---|
| | 184 | <example> |
|---|
| | 185 | <programlisting role="php"> |
|---|
| | 186 | <![CDATA[ |
|---|
| | 187 | echo 'Value: '. Jaws::$Registry->jaws->foo->bar->getValue() . PHP_EOL; |
|---|
| | 188 | echo 'Type: '. Jaws::$Registry->jaws->foo->bar->getType() . PHP_EOL; |
|---|
| | 189 | ]]> |
|---|
| | 190 | </programlisting> |
|---|
| | 191 | </example> |
|---|
| | 192 | </para> |
|---|
| | 193 | |
|---|
| | 194 | <para> |
|---|
| | 195 | This example prints the value of the <literal>\jaws\foo\bar</literal> key |
|---|
| | 196 | along with its type. |
|---|
| | 197 | </para> |
|---|
| | 198 | </sect5> |
|---|
| | 199 | </sect4> |
|---|
| | 200 | |
|---|
| | 201 | <sect4> |
|---|
| | 202 | <title>Set the value of a subkey</title> |
|---|
| | 203 | |
|---|
| | 204 | <para> |
|---|
| | 205 | You can set a key's value by using a method or by setting the value of a |
|---|
| | 206 | property with the same name as the subkey on its parent. |
|---|
| | 207 | </para> |
|---|
| | 208 | |
|---|
| | 209 | <sect5> |
|---|
| | 210 | <title><classname>Jaws_Registry_Key</classname> method</title> |
|---|
| | 211 | <para> |
|---|
| | 212 | <methodsynopsis> |
|---|
| | 213 | <classname>void</classname><methodname>Jaws_Registry_Key::setValue</methodname> |
|---|
| | 214 | <methodparam><type>mixed</type><parameter>$newvalue</parameter></methodparam> |
|---|
| | 215 | </methodsynopsis> |
|---|
| | 216 | </para> |
|---|
| | 217 | |
|---|
| | 218 | <para> |
|---|
| | 219 | <variablelist> |
|---|
| | 220 | <varlistentry> |
|---|
| | 221 | <term><parameter>$newvalue</parameter></term> |
|---|
| | 222 | <listitem>The new value of the key</listitem> |
|---|
| | 223 | </varlistentry> |
|---|
| | 224 | </variablelist> |
|---|
| | 225 | </para> |
|---|
| | 226 | </sect5> |
|---|
| | 227 | |
|---|
| | 228 | <sect5> |
|---|
| | 229 | <title>Magic methods</title> |
|---|
| | 230 | <para> |
|---|
| | 231 | Because the <classname>Jaws_Registry_Key</classname> overloads the set and |
|---|
| | 232 | get operations, it is possible to set a key's value simply by using the key |
|---|
| | 233 | as a property of its parent, as described in the previous sections. The |
|---|
| | 234 | only difference is that you don't have to set the value with the |
|---|
| | 235 | <methodname>setValue</methodname> method; you can assign it directly to the |
|---|
| | 236 | property. The following example illustrates this. |
|---|
| | 237 | </para> |
|---|
| | 238 | |
|---|
| | 239 | <para> |
|---|
| | 240 | <example> |
|---|
| | 241 | <programlisting role="php"> |
|---|
| | 242 | <![CDATA[ |
|---|
| | 243 | Jaws::$Registry->jaws->foo->bar = 'newvalue'; |
|---|
| | 244 | echo Jaws::$Registry->jaws->foo->bar; |
|---|
| | 245 | ]]> |
|---|
| | 246 | </programlisting> |
|---|
| | 247 | </example> |
|---|
| | 248 | </para> |
|---|
| | 249 | |
|---|
| | 250 | <para> |
|---|
| | 251 | This will print the new value of the key, <literal>newvalue</literal>. |
|---|
| | 252 | </para> |
|---|
| | 253 | </sect5> |
|---|