root/trunk/examples/TestConstructor.php

Revision 129, 1.3 kB (checked in by mikey, 1 year ago)

renamed XJConfLoader to XJConf

Line 
1 <?php
2 /**
3  * Example that shows the differant ways of using the constructor definitions.
4  *
5  * @author  Stephan Schmidt <stephan.schmidt@schlund.de>
6  * @author  Frank Kleine <frank.kleine@schlund.de>
7  */
8 require_once '../XJConf/XJConf.php';
9 use net::xjconf::DefinitionParser;
10 use net::xjconf::XmlParser;
11 require 'ConstructorColor.php';
12 require 'CDataColor.php';
13 /**
14  * Example that shows the differant ways of using the constructor definitions.
15  *
16  * @package     XJConf
17  * @subpackage  examples
18  */
19 class TestConstructor
20 {
21     public static function main()
22     {
23         $tagParser = new DefinitionParser();
24         $defs      = $tagParser->parse(getcwd() . '/xml/defines-constructor.xml');
25
26         $conf      = new XmlParser();
27         $conf->setTagDefinitions($defs);
28
29         try {
30             $conf->parse(getcwd() . '/xml/test-constructor.xml');
31         } catch (Exception $e) {
32             echo $e->getTraceAsString();
33             exit(0);
34         }
35         
36         $color = $conf->getConfigValue('color');
37         var_dump($color);
38         $color = $conf->getConfigValue('color-no-atts');
39         var_dump($color);
40         $color = $conf->getConfigValue('color2');
41         var_dump($color);
42         $color = $conf->getConfigValue('color3');
43         var_dump($color);
44     }
45 }
46 TestConstructor::main();
47 ?>
Note: See TracBrowser for help on using the browser.