root/tags/RELEASE_0_1_1/examples/TestAttributesRequired.php

Revision 43, 1.2 kB (checked in by schst, 2 years ago)

New feature: It is now possible to use dynamic setter methods based on the value of an attribute of a tag.

Line 
1 <?php
2 /**
3  * Example that shows the effect of required attributes that have not been set.
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 'Color.php';
14 /**
15  * Example that shows the effect of required attributes that have not been set.
16  *
17  * @package     XJConf
18  * @subpackage  examples
19  */
20 class TestAttributesRequired
21 {
22     public static function main()
23     {
24         $tagParser = new DefinitionParser();
25         $defs      = $tagParser->parse(getcwd() . '/xml/defines-attributes-required.xml');
26
27         $conf      = new XmlParser();
28         try {
29             $conf->setTagDefinitions($defs);
30             $conf->parse(getcwd() . '/xml/test-attributes-required.xml');
31             $color = $conf->getConfigValue('red');
32             var_dump($color);
33         } catch (Exception $e) {
34             echo 'Caught expected Exception with message: "' . $e->getMessage() . '", showing trace: ';
35             var_dump($e->getTrace());
36             exit(0);
37         }
38     }
39 }
40 TestAttributesRequired::main();
41 ?>
Note: See TracBrowser for help on using the browser.