Changeset 94
- Timestamp:
- 03/05/07 16:41:37 (2 years ago)
- Files:
-
- trunk/XJConf/DefinedTag.php (modified) (2 diffs)
- trunk/XJConf/DefinitionParser.php (modified) (6 diffs)
- trunk/XJConf/GenericTag.php (modified) (1 diff)
- trunk/XJConf/Tag.php (modified) (1 diff)
- trunk/XJConf/XmlParser.php (modified) (1 diff)
- trunk/XJConf/converters/AbstractObjectValueConverter.php (modified) (2 diffs)
- trunk/XJConf/definitions/AttributeDefinition.php (modified) (2 diffs)
- trunk/XJConf/definitions/CDataDefinition.php (modified) (1 diff)
- trunk/XJConf/definitions/ChildDefinition.php (modified) (1 diff)
- trunk/XJConf/definitions/ConstructorDefinition.php (modified) (1 diff)
- trunk/XJConf/definitions/Definition.php (modified) (1 diff)
- trunk/XJConf/definitions/FactoryMethodDefinition.php (modified) (1 diff)
- trunk/XJConf/definitions/MethodCallTagDefinition.php (added)
- trunk/XJConf/definitions/TagDefinition.php (modified) (5 diffs)
- trunk/XJConf/definitions/ValueModifier.php (added)
- trunk/XJConf/definitions/handler/MethodCallTagDefinitionHandler.php (added)
- trunk/examples/ExampleMethods.php (added)
- trunk/examples/xml/defines-method.xml (added)
- trunk/examples/xml/test-method.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/XJConf/DefinedTag.php
r62 r94 267 267 * @param TagDefinition $tagDef 268 268 */ 269 public function setDefinition( TagDefinition $tagDef)269 public function setDefinition(Definition $tagDef) 270 270 { 271 271 if ($tagDef instanceof ConcreteTagDefinition) { … … 273 273 return; 274 274 } 275 275 276 276 $this->tagDef = clone $tagDef; 277 $this->tagDef->setType($this->getAttribute($this->tagDef->getConcreteTypeAttributeName())); 277 if ($tagDef instanceof TagDefinition) { 278 $this->tagDef->setType($this->getAttribute($this->tagDef->getConcreteTypeAttributeName())); 279 } 278 280 } 279 281 trunk/XJConf/DefinitionParser.php
r60 r94 11 11 'definitions.ConstructorDefinition', 12 12 'definitions.FactoryMethodDefinition', 13 'definitions.MethodCallTagDefinition', 13 14 'definitions.NamespaceDefinition', 14 15 'definitions.NamespaceDefinitions', … … 84 85 * Sets the node types depending on your PHP version using the constants 85 86 * defined by the XMLReader PHP extension. 86 * 87 * 87 88 * @param array<String,XJConfClassLoader> $classLoaders optional 88 89 */ … … 125 126 return $this->defs; 126 127 } 127 128 128 129 /** 129 130 * check whether a class loader exists for given namespace … … 136 137 return (isset($this->classLoaders[$namespace])); 137 138 } 138 139 139 140 /** 140 141 * return the class loader for the given namespace … … 145 146 public function getClassLoader($namespace) 146 147 { 147 148 148 149 if ($this->hasClassLoader($namespace) == true) { 149 150 return $this->classLoaders[$namespace]; 150 151 } 151 152 152 153 return null; 153 154 } … … 245 246 return; 246 247 } 247 248 248 249 // create the appropriate definition handler and use this 249 250 // to create the required definition trunk/XJConf/GenericTag.php
r14 r94 279 279 $this->value = $value; 280 280 } 281 282 public function getDefinition() { 283 return null; 284 } 281 285 } 282 286 ?> trunk/XJConf/Tag.php
r14 r94 124 124 public function getSetterMethod(); 125 125 126 public function getDefinition(); 127 126 128 /** 127 129 * Checks, whether the tag supports indexed children trunk/XJConf/XmlParser.php
r47 r94 250 250 } 251 251 252 if ($this->tagDefs->isTagDefined($namespaceURI, $sName) == false) { 253 throw new UnknownTagException('Unknown tag ' . $sName . ' in namespace ' . $namespaceURI); 252 $newDef = null; 253 $lastTag = end($this->tagStack); 254 if ($lastTag != null) { 255 $lastDef = $lastTag->getDefinition(); 256 if ($lastDef != null) { 257 $newDef = $lastDef->getChildDefinitionByTagName($sName); 258 } 259 } 260 if ($newDef === null) { 261 if ($this->tagDefs->isTagDefined($namespaceURI, $sName) == false) { 262 throw new UnknownTagException('Unknown tag ' . $sName . ' in namespace ' . $namespaceURI); 263 } 264 $newDef = $this->tagDefs->getTagDefinition($namespaceURI, $sName); 254 265 } 255 266 256 267 $tag = new DefinedTag($sName, $atts); 257 268 // fetch the defintion for this tag 258 $tag->setDefinition($ this->tagDefs->getTagDefinition($namespaceURI, $sName));269 $tag->setDefinition($newDef); 259 270 } 260 271 trunk/XJConf/converters/AbstractObjectValueConverter.php
r62 r94 23 23 */ 24 24 protected $className; 25 26 /** 27 * Enter description here... 28 * 29 * @param Tag $tag 30 * @param TagDefinition $def 31 * @param unknown_type $instance 32 */ 33 protected function callMethods(Tag $tag, TagDefinition $def, $instance) { 34 $children = $tag->getChildren(); 35 foreach ($children as $child) { 36 if (!$child instanceof ValueModifier) { 37 continue; 38 } 39 } 40 } 25 41 26 42 /** … … 71 87 $class = new ReflectionClass(get_class($instance)); 72 88 foreach ($children as $child) { 89 73 90 if (in_array($child->getName(), $ignore) == true) { 91 continue; 92 } 93 94 $childDef = $child->getDefinition(); 95 if ($childDef instanceof ValueModifier) { 96 $childDef->modifyValue($instance, $child); 74 97 continue; 75 98 } trunk/XJConf/definitions/AttributeDefinition.php
r59 r94 131 131 } 132 132 133 134 133 135 if (null === $value) { 134 136 if ($this->isRequired() == true) { … … 289 291 return $this->valueConverter; 290 292 } 293 294 /** 295 * This definition does not support named child definitions 296 * 297 * @param string $name 298 * @return Definition 299 */ 300 public function getChildDefinitionByTagName($name) { 301 return null; 302 } 291 303 } 292 304 ?> trunk/XJConf/definitions/CDataDefinition.php
r63 r94 178 178 return $this->valueConverter; 179 179 } 180 181 /** 182 * This definition does not support named child definitions 183 * 184 * @param string $name 185 * @return Definition 186 */ 187 public function getChildDefinitionByTagName($name) { 188 return null; 189 } 180 190 } 181 191 ?> trunk/XJConf/definitions/ChildDefinition.php
r43 r94 143 143 } 144 144 145 145 /** 146 * This definition does not support named child definitions 147 * 148 * @param string $name 149 * @return Definition 150 */ 151 public function getChildDefinitionByTagName($name) { 152 return null; 153 } 146 154 } 147 155 ?> trunk/XJConf/definitions/ConstructorDefinition.php
r65 r94 160 160 return $this->params; 161 161 } 162 163 /** 164 * This definition does not support named child definitions 165 * 166 * @param string $name 167 * @return Definition 168 */ 169 public function getChildDefinitionByTagName($name) { 170 return null; 171 } 162 172 } 163 173 ?> trunk/XJConf/definitions/Definition.php
r43 r94 82 82 */ 83 83 public function getChildDefinitions(); 84 85 public function getChildDefinitionByTagName($name); 84 86 } 85 87 ?> trunk/XJConf/definitions/FactoryMethodDefinition.php
r66 r94 179 179 return $this->params; 180 180 } 181 182 /** 183 * This definition does not support named child definitions 184 * 185 * @param string $name 186 * @return Definition 187 */ 188 public function getChildDefinitionByTagName($name) { 189 return null; 190 } 181 191 } 182 192 ?> trunk/XJConf/definitions/TagDefinition.php
r93 r94 78 78 */ 79 79 protected $valueConverter; 80 81 /** 82 * Methods to call on this tag 83 * 84 * @var array 85 */ 86 protected $methods = array(); 87 88 protected $childDefs = array(); 89 80 90 /** 81 91 * definition of tag content … … 271 281 return; 272 282 } 283 $this->childDefs[] = $def; 273 284 } 274 285 … … 420 431 $this->classLoader = $classLoader; 421 432 } 422 433 423 434 /** 424 435 * extends itsself from another tag definition 425 * 436 * 426 437 * @param TagDefinition $tagDefinition the tag definition to extend from 427 438 */ … … 438 449 439 450 /** 451 * Get the methods 452 * 453 * @return array 454 */ 455 public function getMethods() { 456 return $this->methods; 457 } 458 459 /** 440 460 * Get the value converter for this tag 441 461 * … … 458 478 return $this->valueConverter; 459 479 } 480 481 public function getChildDefinitionByTagName($name) { 482 foreach ($this->childDefs as $childDef) { 483 if ($childDef->getName() == $name) { 484 return $childDef; 485 } 486 } 487 return null; 488 } 460 489 } 461 490 ?>
