root/tags/RELEASE_0_2_0/examples/TestDynamicTypes.php

Revision 53, 1.1 kB (checked in by mikey, 2 years ago)

added possibility of dynamic types (proof of concept, more work has to be put into this if it gets approved)

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