Changeset 13
- Timestamp:
- 08/27/06 02:02:33 (2 years ago)
- Files:
-
- trunk/XJConf/definitions/TagDefinition.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/XJConf/definitions/TagDefinition.php
r7 r13 1 1 <?php 2 /** 3 * Definition of an XML tag. 4 * 5 * @author Stephan Schmidt <stephan.schmidt@schlund.de> 6 * @author Frank Kleine <frank.kleine@schlund.de> 7 */ 2 8 XJConfLoader::load('converters.factories.ValueConverterFactoryChain', 3 9 'definitions.AttributeDefinition', … … 10 16 ); 11 17 /** 12 * Defin tion of an XML tag18 * Definition of an XML tag. 13 19 * 14 * @author Stephan Schmidt <stephan.schmidt@schlund.de> 20 * @package XJConf 21 * @subpackage definitions 15 22 */ 16 23 class TagDefinition implements Definition … … 114 121 * Possible definitions are: 115 122 * - AttributeDefinition 116 * - ConstrcutorDefinition 123 * - ConstructorDefinition 124 * - FactoryMethodDefinition 117 125 * - CDataDefinition 118 126 * … … 230 238 * Get the type of the tag 231 239 * 232 * @return string240 * @return string 233 241 */ 234 242 public function getValueType(Tag $tag) … … 271 279 * @param Tag $tag tag that will be converted 272 280 * @return mixed converted value 273 * @throws ValueConversionException281 * @throws ValueConversionException 274 282 */ 275 283 public function convertValue(Tag $tag) … … 288 296 $this->constructor->addChildDefinition(new CDataDefinition()); 289 297 } catch (Exception $e) { 290 throw new ValueConversionException('Could not create constructor object ', $e);298 throw new ValueConversionException('Could not create constructor object: ' . $e->getMessage()); 291 299 } 292 300 } … … 343 351 $method->invoke($instance, $val); 344 352 } catch (ReflectionException $re) { 345 throw new ValueConversionException('Could not set attribute "' . $att->getName() . '" of "' . $this->getType() . '" using "' . $att->getSetterMethod() . '()", exception message: "' . $re .getMessage() . '".');353 throw new ValueConversionException('Could not set attribute "' . $att->getName() . '" of "' . $this->getType() . '" using "' . $att->getSetterMethod() . '()", exception message: "' . $re->getMessage() . '".'); 346 354 } 347 355 } … … 373 381 374 382 try { 375 $class->getMethod($child->getSetterMethod())->invoke($instance, array($child->getConvertedValue()));383 $class->getMethod($child->getSetterMethod())->invoke($instance, $child->getConvertedValue()); 376 384 } catch (ReflectionException $re) { 377 throw new ValueConversionException('Could not add child "' . $child->getKey() . '" to "' . $this->getType() . '" using "' . $child->getSetterMethod() . '()", exception message: "' . $re .getMessage() . '".');385 throw new ValueConversionException('Could not add child "' . $child->getKey() . '" to "' . $this->getType() . '" using "' . $child->getSetterMethod() . '()", exception message: "' . $re->getMessage() . '".'); 378 386 } 379 387 } … … 387 395 public function supportsIndexedChildren() 388 396 { 389 // TODO: Find a better (and working) way to do this check.390 397 if ($this->getType() == 'array') { 391 398 return true; … … 398 405 * Return all child definitions. 399 406 * 400 * @return array 401 */ 402 public function getChildDefinitions() { 407 * @return array 408 */ 409 public function getChildDefinitions() 410 { 403 411 $children = $this->atts; 404 412 if ($this->factoryMethod instanceof Definition) { 405 413 $children[] = $this->factoryMethod; 406 414 } 415 407 416 if ($this->constructor instanceof Definition) { 408 417 $children[] = $this->constructor; 409 418 } 419 410 420 if ($this->cdata instanceof Definition) { 411 421 $children[] = $this->cdata; 412 422 } 423 413 424 return $children; 414 425 } … … 421 432 private function getValueConverter() 422 433 { 423 if ( $this->valueConverter == null) {434 if (null == $this->valueConverter) { 424 435 $this->valueConverter = ValueConverterFactoryChain::getFactory($this)->createValueConverter($this); 425 436 } 437 426 438 return $this->valueConverter; 427 439 }
