Changeset 15

Show
Ignore:
Timestamp:
08/27/06 23:09:45 (2 years ago)
Author:
schst
Message:

Fixed parameters in constructor (requires PHP 5.1.3 or a single argument in the constructor to function properly)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/XJConf/converters/ConstructorValueConverter.php

    r14 r15  
    5353        try { 
    5454                $refClass = new ReflectionClass($this->className); 
    55                 $instance = $refClass->newInstance($cParams); 
     55                if (method_exists($refClass, 'newInstanceArgs')) { 
     56                   $instance = $refClass->newInstanceArgs($cParams); 
     57                } elseif (count($cParams) == 1) { 
     58                    $instance = $refClass->newInstance($cParams[0]); 
     59                } else { 
     60                    throw new ValueConversionException('Could not create instance of "' . $this->className . '" as Reflection does not support newInstanceArgs().'); 
     61                } 
    5662        } catch (ReflectionException $re) { 
    5763            throw new ValueConversionException('Could not create instance of "' . $this->className . '": ' . $re->getMessage()); 
  • trunk/examples/xml/defines-primitives.xml

    r14 r15  
    44 
    55        <tag name="color" type="ColorPrimitives"> 
     6        <constructor><cdata type="string"/></constructor> 
    67                <attribute name="red" type="int"/> 
    78                <attribute name="green" type="int"/> 
  • trunk/examples/xml/test-primitives.xml

    r14 r15  
    44        <bool id="bool">true</bool> 
    55 
    6         <color red="100" green="50" blue="20"/
     6        <color red="100" green="50" blue="20">My color</color
    77</configuration>