root/tags/RELEASE_0_1_2/examples/TestDynamicSetters.php

Revision 43, 1.0 kB (checked in by schst, 2 years ago)

New feature: It is now possible to use dynamic setter methods based on the value of an attribute of a tag.

Line 
1 <?php
2 /**
3  * Example that shows how to use a setter method that's dynamically
4  * created from an attribute of a tag.
5  *
6  * @author  Stephan Schmidt <stephan.schmidt@schlund.de>
7  */
8 require_once '../XJConf/XJConfLoader.php';
9 XJConfLoader::load('DefinitionParser',
10                    'XmlParser'
11 );
12
13 require_once 'DynamicSetterClass.php';
14
15 /**
16  * Example that shows how to use same classes with differant tags.
17  *
18  * @package     XJConf
19  * @subpackage  examples
20  */
21 class TestDynamicSetters
22 {
23     public static function main()
24     {
25         $tagParser = new DefinitionParser();
26         $defs      = $tagParser->parse(getcwd() . '/xml/defines-dynamic-setters.xml');
27
28         $conf      = new XmlParser();
29         $conf->setTagDefinitions($defs);
30
31         try {
32             $conf->parse(getcwd() . '/xml/test-dynamic-setters.xml');
33         } catch (Exception $e) {
34             echo $e->getMessage();
35             var_dump($e->getTrace());
36             exit(0);
37         }
38
39         $foo = $conf->getConfigValue('class');
40         var_dump($foo);
41     }
42 }
43 TestDynamicSetters::main();
44 ?>
Note: See TracBrowser for help on using the browser.