root/tags/RELEASE_0_2_1/examples/TestConstructor.php

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

added constructor cdata example and test

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/XJConfLoader.php';
9 XJConfLoader::load('DefinitionParser',
10                    'XmlParser',
11                    'ext.Extension'
12 );
13 require 'ConstructorColor.php';
14 require 'CDataColor.php';
15 /**
16  * Example that shows the differant ways of using the constructor definitions.
17  *
18  * @package     XJConf
19  * @subpackage  examples
20  */
21 class TestConstructor
22 {
23     public static function main()
24     {
25         $tagParser = new DefinitionParser();
26         $defs      = $tagParser->parse(getcwd() . '/xml/defines-constructor.xml');
27
28         $conf      = new XmlParser();
29         $conf->setTagDefinitions($defs);
30
31         try {
32             $conf->parse(getcwd() . '/xml/test-constructor.xml');
33         } catch (Exception $e) {
34             echo $e->getTraceAsString();
35             exit(0);
36         }
37         
38         $color = $conf->getConfigValue('color');
39         var_dump($color);
40         $color = $conf->getConfigValue('color-no-atts');
41         var_dump($color);
42         $color = $conf->getConfigValue('color2');
43         var_dump($color);
44         $color = $conf->getConfigValue('color3');
45         var_dump($color);
46     }
47 }
48 TestConstructor::main();
49 ?>
Note: See TracBrowser for help on using the browser.