Changeset 10
- Timestamp:
- 08/26/06 21:23:14 (2 years ago)
- Files:
-
- trunk/XJConf/definitions/CDataDefinition.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/XJConf/definitions/CDataDefinition.php
r6 r10 1 1 <?php 2 XJConfLoader::load('converters.ObjectValueConverter', 3 'converters.PrimitiveValueConverter', 2 /** 3 * Definition for the character data inside a tag. 4 * 5 * @author Stephan Schmidt <stephan.schmidt@schlund.de> 6 * @author Frank Kleine <frank.kleine@schlund.de> 7 */ 8 XJConfLoader::load('converters.factories.ValueConverterFactoryChain', 4 9 'definitions.Definition' 5 10 ); … … 10 15 * of the tag, while casting it to the desired class. 11 16 * 12 * @author Stephan Schmidt <stephan.schmidt@schlund.de> 17 * @package XJConf 18 * @subpackage definitions 13 19 */ 14 20 class CDataDefinition implements Definition … … 41 47 { 42 48 if (null == $type) { 43 $this->type = 'string'; 44 $this->valueConverter = new ObjectValueConverter('string'); 45 } else { 46 $this->type = $type; 47 48 if (in_array($type, get_declared_classes()) == false) { 49 $this->valueConverter = new PrimitiveValueConverter($this->type); 50 } else { 51 $this->valueConverter = new ObjectValueConverter($this->type); 52 } 49 $type = 'string'; 53 50 } 51 52 $this->type = $type; 54 53 } 55 54 … … 81 80 /** 82 81 * Character data cannot have any child definitions 82 * 83 * @param Definition $def 83 84 */ 84 85 public function addChildDefinition(Definition $def) … … 95 96 public function convertValue(Tag $tag) 96 97 { 97 if (in_array($this->type, get_declared_classes()) == false) { 98 $this->valueConverter = new PrimitiveValueConverter($this->type); 99 } else { 100 $this->valueConverter = new ObjectValueConverter($this->type); 101 } 102 $instance = $this->valueConverter->convertValue(array($tag->getContent())); 98 $instance = $this->getValueConverter()->convertValue(array($tag->getContent())); 103 99 return $instance; 104 100 } … … 121 117 */ 122 118 public function getValueType(Tag $tag) { 123 return $this-> valueConverter->getType();119 return $this->getValueConverter()->getType(); 124 120 } 125 121 … … 137 133 * Return all child definitions. 138 134 * 139 * Currently ,it is not possible to add any child135 * Currently it is not possible to add any child 140 136 * definitions to cdata 141 137 * 142 * @return array138 * @return array 143 139 */ 144 140 public function getChildDefinitions() { 145 141 return array(); 146 142 } 143 144 /** 145 * Get the value converter for this character data 146 * 147 * @return ValueConverter 148 */ 149 private function getValueConverter() 150 { 151 if ($this->valueConverter == null) { 152 $this->valueConverter = ValueConverterFactoryChain::getFactory($this)->createValueConverter($this); 153 } 154 155 return $this->valueConverter; 156 } 147 157 } 148 158 ?>
