root/tags/RELEASE_0_2_0/examples/ExampleMethods.php

Revision 94, 0.6 kB (checked in by schst, 2 years ago)

Add the possibility to call setter methods with any number of arguments. This fixed ticket #9. But beware: this feature is in alpha stage, it may break existing applications.

Line 
1 <?php
2 /**
3  * Example that shows how to call methods on objects
4  *
5  * @author  Stephan Schmidt <schst@xjconf.net>
6  */
7
8 require_once '../XJConf/XJConfLoader.php';
9 XJConfLoader::load('DefinitionParser',
10                    'XmlParser'
11 );
12
13 class Properties {
14     protected $props = array();
15
16     public function setProperty($name, $value) {
17         $this->props[$name] = $value;
18     }
19 }
20
21 $tagParser = new DefinitionParser();
22 $defs = $tagParser->parse(getcwd() . '/xml/defines-method.xml');
23
24 $conf = new XmlParser();
25 $conf->setTagDefinitions($defs);
26
27 $conf->parse(getcwd() . '/xml/test-method.xml');
28
29 print_r($conf->getConfigValue('props'));
30 ?>
Note: See TracBrowser for help on using the browser.