root/tags/RELEASE_0_1_1/examples/TestEmptyConstructor.php

Revision 23, 0.8 kB (checked in by schst, 2 years ago)

Added example that shows the use of an empty constructor.

Line 
1 <?php
2 require_once '../XJConf/XJConfLoader.php';
3 XJConfLoader::load('DefinitionParser',
4                    'XmlParser'
5 );
6 error_reporting(E_ALL | E_STRICT);
7
8 require 'EmptyConstructorClass.php';
9 require 'ColorPrimitives.php';
10 /**
11  * @author Stephan Schmidt <stephan.schmidt@schlund.de>
12  */
13 class TestEmptyConstructor
14 {
15
16     public static function main() {
17         $tagParser = new DefinitionParser();
18         $defs = $tagParser->parse(getcwd() . '/xml/defines-empty-constructor.xml');
19
20         $conf = new XmlParser();
21         $conf->setTagDefinitions($defs);
22
23         try {
24             $conf->parse(getcwd() . '/xml/test-empty-constructor.xml');
25         } catch (Exception $e) {
26             throw $e;
27             exit();
28         }
29
30         $foo = $conf->getConfigValue('foo');
31         var_dump($foo->getDataFromConstructor());
32     }
33 }
34 TestEmptyConstructor::main();
35 ?>
Note: See TracBrowser for help on using the browser.