Changeset 13

Show
Ignore:
Timestamp:
08/27/06 02:02:33 (2 years ago)
Author:
mikey
Message:

- fix: do not convert second argument of ReflectionMethod::invoke() into an array
- fix: use correct operators for exception messages
- corrected doc blocks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/XJConf/definitions/TagDefinition.php

    r7 r13  
    11<?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 */ 
    28XJConfLoader::load('converters.factories.ValueConverterFactoryChain', 
    39                   'definitions.AttributeDefinition', 
     
    1016); 
    1117/** 
    12  * Defintion of an XML tag 
     18 * Definition of an XML tag. 
    1319 * 
    14  * @author Stephan Schmidt <stephan.schmidt@schlund.de> 
     20 * @package     XJConf 
     21 * @subpackage  definitions 
    1522 */ 
    1623class TagDefinition implements Definition 
     
    114121     * Possible definitions are: 
    115122     * - AttributeDefinition 
    116      * - ConstrcutorDefinition 
     123     * - ConstructorDefinition 
     124     * - FactoryMethodDefinition 
    117125     * - CDataDefinition 
    118126     * 
     
    230238     * Get the type of the tag 
    231239     * 
    232      * @return  string 
     240     * @return  string 
    233241     */ 
    234242    public function getValueType(Tag $tag) 
     
    271279         * @param   Tag    $tag  tag that will be converted 
    272280         * @return  mixed  converted value 
    273          * @throws ValueConversionException 
     281         * @throws ValueConversionException 
    274282         */ 
    275283        public function convertValue(Tag $tag) 
     
    288296                $this->constructor->addChildDefinition(new CDataDefinition()); 
    289297            } catch (Exception $e) { 
    290                 throw new ValueConversionException('Could not create constructor object', $e); 
     298                throw new ValueConversionException('Could not create constructor object: ' . $e->getMessage()); 
    291299            } 
    292300        } 
     
    343351                $method->invoke($instance, $val); 
    344352            } 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() . '".'); 
    346354            } 
    347355        } 
     
    373381 
    374382            try { 
    375                 $class->getMethod($child->getSetterMethod())->invoke($instance, array($child->getConvertedValue())); 
     383                $class->getMethod($child->getSetterMethod())->invoke($instance, $child->getConvertedValue()); 
    376384            } 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() . '".'); 
    378386            } 
    379387        } 
     
    387395        public function supportsIndexedChildren() 
    388396        { 
    389                 // TODO: Find a better (and working) way to do this check. 
    390397                if ($this->getType() == 'array') { 
    391398                        return true; 
     
    398405     * Return all child definitions. 
    399406     * 
    400      * @return array 
    401      */ 
    402     public function getChildDefinitions() { 
     407     * @return  array 
     408     */ 
     409    public function getChildDefinitions() 
     410    { 
    403411        $children = $this->atts; 
    404412        if ($this->factoryMethod instanceof Definition) { 
    405413            $children[] = $this->factoryMethod; 
    406414        } 
     415         
    407416        if ($this->constructor instanceof Definition) { 
    408417            $children[] = $this->constructor; 
    409418        } 
     419         
    410420        if ($this->cdata instanceof Definition) { 
    411421            $children[] = $this->cdata; 
    412422        } 
     423         
    413424        return $children; 
    414425    } 
     
    421432    private function getValueConverter() 
    422433    { 
    423         if ($this->valueConverter == null) { 
     434        if (null == $this->valueConverter) { 
    424435            $this->valueConverter = ValueConverterFactoryChain::getFactory($this)->createValueConverter($this); 
    425436        } 
     437         
    426438        return $this->valueConverter; 
    427439    }