root/trunk/examples/ExampleClassLoader.php

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

renamed XJConfLoader to XJConf

Line 
1 <?php
2 /**
3  * Example that shows how to use class loaders.
4  *
5  * @author  Frank Kleine <frank.kleine@schlund.de>
6  */
7 require_once '../XJConf/XJConf.php';
8 use net::xjconf::DefinitionParser;
9 use net::xjconf::XmlParser;
10 use net::xjconf::XJConfClassLoader;
11 require 'ClassLoader.php';
12 /**
13  * Example that shows how to use class loaders.
14  *
15  * @package     XJConf
16  * @subpackage  examples
17  */
18 class ExampleClassLoader
19 {
20     public static function main()
21     {
22         $tagParser = new DefinitionParser(array('http://xjconf.net/example/ClassLoader' => new ClassLoader()));
23         $defs      = $tagParser->parse(getcwd() . '/xml/defines-classloader.xml');
24         
25         $conf      = new XmlParser();
26         $conf->setTagDefinitions($defs);
27         try {
28             $conf->parse(getcwd() . '/xml/test-classloader.xml');
29         } catch (Exception $e) {
30             echo $e->getTraceAsString();
31             exit(0);
32         }
33         
34         $nestedClass = $conf->getConfigValue('nestedClass');
35         echo 'nestedClass:';
36         var_dump($nestedClass);
37         
38         $otherClass = $conf->getConfigValue('otherClass');
39         echo 'otherClass:';
40         var_dump($otherClass);
41     }
42 }
43 ExampleClassLoader::main();
44 ?>
Note: See TracBrowser for help on using the browser.