root/trunk/examples/TestDynamicSetters.php

Revision 129, 1.0 kB (checked in by mikey, 10 months ago)

renamed XJConfLoader to XJConf

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/XJConf.php';
9 use net::xjconf::DefinitionParser;
10 use net::xjconf::XmlParser;
11
12 require_once 'DynamicSetterClass.php';
13
14 /**
15  * Example that shows how to use same classes with differant tags.
16  *
17  * @package     XJConf
18  * @subpackage  examples
19  */
20 class TestDynamicSetters
21 {
22     public static function main()
23     {
24         $tagParser = new DefinitionParser();
25         $defs      = $tagParser->parse(getcwd() . '/xml/defines-dynamic-setters.xml');
26
27         $conf      = new XmlParser();
28         $conf->setTagDefinitions($defs);
29
30         try {
31             $conf->parse(getcwd() . '/xml/test-dynamic-setters.xml');
32         } catch (Exception $e) {
33             echo $e->getMessage();
34             var_dump($e->getTrace());
35             exit(0);
36         }
37
38         $foo = $conf->getConfigValue('class');
39         var_dump($foo);
40     }
41 }
42 TestDynamicSetters::main();
43 ?>
Note: See TracBrowser for help on using the browser.