root/trunk/examples/TestDynamicTypes.php

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