Changeset 1042
- Timestamp:
- 11/15/07 17:10:19 (8 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotation.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorFactoryMappingDecorator.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotation.php
r731 r1042 44 44 */ 45 45 protected $defaultValue = null; 46 /** 47 * list of error mappings 48 * 49 * @var array<array<string,string>> 50 */ 51 protected $mappings = array(); 46 52 47 53 /** … … 96 102 97 103 /** 104 * sets the error mapping 105 * 106 * @param string $errorMapping 107 */ 108 public function setErrorMapping($errorMapping) 109 { 110 $mappings = explode(':', $errorMapping); 111 foreach ($mappings as $mapping) { 112 $errorIds = explode('=>', $mapping); 113 $this->mappings[trim($errorIds[0])] = trim($errorIds[1]); 114 } 115 } 116 117 /** 98 118 * returns the filter defined by the annotation 99 119 * … … 127 147 if (null != $this->rveFactoryClass) { 128 148 $rveFactory = $this->rveFactoryClass->newInstance(); 129 if (($rveFactory instanceof stubRequestValueErrorFactory) == false) {149 if (($rveFactory instanceof stubRequestValueErrorFactory) === false) { 130 150 throw new stubRequestBrokerException('Created request value error factory is not an instance of stubRequestValueErrorFactory'); 131 151 } … … 135 155 } 136 156 137 return $rveFactory; 157 if (count($this->mappings) === 0) { 158 return $rveFactory; 159 } 160 161 stubClassLoader::load('net.stubbles.ipo.request.stubRequestValueErrorFactoryMappingDecorator'); 162 $rveMappingDecorator = new stubRequestValueErrorFactoryMappingDecorator($rveFactory); 163 foreach ($this->mappings as $oldErrorId => $newErrorId) { 164 $rveMappingDecorator->addMapping($oldErrorId, $newErrorId); 165 } 166 167 return $rveMappingDecorator; 138 168 } 139 169 … … 147 177 return stubAnnotation::TARGET_METHOD + stubAnnotation::TARGET_PROPERTY; 148 178 } 149 150 179 } 151 180 ?> trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorFactoryMappingDecorator.php
r1037 r1042 53 53 54 54 /** 55 * returns current mappings where key is old error id and value is new error id 56 * 57 * @return array<string,string> 58 */ 59 public function getMappings() 60 { 61 return $this->mappings; 62 } 63 64 /** 55 65 * creates the RequestValueError with the id from the given source 56 66 * trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php
r731 r1042 105 105 106 106 /** 107 * test that mapping is added correct 108 */ 109 public function testMappedRequestErrorValueFactory() 110 { 111 $abstractFilterAnnotation = new TeststubAbstractFilterAnnotation(); 112 $abstractFilterAnnotation->setErrorMapping('FIELD_EMPTY=>FOO_EMPTY:TOO_SMALL=>TOO_GREAT'); 113 $rveFactory = $abstractFilterAnnotation->getRVEFactory(); 114 $this->assertIsA($rveFactory, 'stubRequestValueErrorFactoryMappingDecorator'); 115 $this->assertEqual($rveFactory->getMappings(), array('FIELD_EMPTY' => 'FOO_EMPTY', 116 'TOO_SMALL' => 'TOO_GREAT' 117 ) 118 ); 119 } 120 121 /** 107 122 * test that the correct RequestErrorValueFactory is created 108 123 */
