root/branches/PRE_NAMESPACES/examples/ExampleClassLoader.php

Revision 46, 1.2 kB (checked in by mikey, 2 years ago)

added possibility to use class loaders

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