Changeset 77
- Timestamp:
- 12/19/06 20:09:16 (2 years ago)
- Files:
-
- trunk/XJConf/converters/StaticClassValueConverter.php (added)
- trunk/XJConf/converters/factories/StaticClassValueConverterFactory.php (added)
- trunk/XJConf/converters/factories/ValueConverterFactoryChain.php (modified) (2 diffs)
- trunk/XJConf/definitions/TagDefinition.php (modified) (7 diffs)
- trunk/XJConf/definitions/handler/AbstractTagDefinitionHandler.php (modified) (2 diffs)
- trunk/XJConf/definitions/handler/ConcreteTagDefinitionHandler.php (modified) (1 diff)
- trunk/autopackage2.php (modified) (1 diff)
- trunk/examples/TestStaticClass.php (added)
- trunk/examples/xml/defines-static.xml (added)
- trunk/examples/xml/test-static.xml (added)
- trunk/package.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/XJConf/converters/factories/ValueConverterFactoryChain.php
r22 r77 11 11 'converters.factories.ConstructorValueConverterFactory', 12 12 'converters.factories.FactoryMethodValueConverterFactory', 13 'converters.factories.StaticClassValueConverterFactory', 13 14 'definitions.Definition' 14 15 ); … … 59 60 ValueConverterFactoryChain::push(new PrimitiveValueConverterFactory()); 60 61 ValueConverterFactoryChain::push(new ArrayValueConverterFactory()); 62 ValueConverterFactoryChain::push(new StaticClassValueConverterFactory()); 61 63 ValueConverterFactoryChain::push(new ConstructorValueConverterFactory()); 62 64 ValueConverterFactoryChain::push(new FactoryMethodValueConverterFactory()); trunk/XJConf/definitions/TagDefinition.php
r62 r77 91 91 */ 92 92 protected $classLoader = null; 93 /** 94 * Whether the calls should be made statically or not 95 * 96 * @var boolean 97 */ 98 protected $static = false; 93 99 94 100 /** … … 132 138 return $this->classLoader->getType($this->type); 133 139 } 134 140 135 141 return $this->type; 142 } 143 144 /** 145 * Set whether calls should be made statically (true) 146 * or an instance of the class should be created (false) 147 * 148 * @param boolean $static 149 */ 150 public function setStatic($static) { 151 $this->static = $static; 152 } 153 154 /** 155 * get the type of the tag 156 * 157 * @return string 158 */ 159 public function isStatic() 160 { 161 return $this->static; 136 162 } 137 163 … … 150 176 $data = ''; 151 177 } 152 178 153 179 // no constructor definition has been set, 154 180 // create a new one … … 220 246 221 247 if ($def instanceof FactoryMethodDefinition) { 248 if ($this->isStatic()) { 249 throw new InvalidTagDefinitionException('Static classes may not have a factory method defined.'); 250 } 222 251 $this->factoryMethod = $def; 223 252 return; … … 225 254 226 255 if ($def instanceof ConstructorDefinition) { 256 if ($this->isStatic()) { 257 throw new InvalidTagDefinitionException('Static classes may not have a constructor defined.'); 258 } 227 259 $this->constructor = $def; 228 260 return; … … 371 403 return false; 372 404 } 373 405 374 406 /** 375 407 * set the class loader for this tag … … 392 424 throw new ValueConversionException('No type set. Can not create ValueConverter.'); 393 425 } 394 426 395 427 if (null != $this->classLoader) { 396 428 $this->classLoader->loadClass($this->type); 397 429 } 398 430 399 431 if (null == $this->valueConverter) { 400 432 $this->valueConverter = ValueConverterFactoryChain::getFactory($this)->createValueConverter($this); trunk/XJConf/definitions/handler/AbstractTagDefinitionHandler.php
r61 r77 54 54 throw new InvalidTagDefinitionException('The <abstractTag> tag is missing the abstractType attribute.'); 55 55 } 56 56 57 57 if (isset($atts['concreteTypeAttribute']) == false) { 58 58 throw new InvalidTagDefinitionException('The <abstractTag> tag is missing the concreteTypeAttribute attribute.'); … … 84 84 $def->setSetterMethod($atts['setter']); 85 85 } 86 86 87 // static 88 if (isset($atts['static']) == true && strtolower($atts['static']) == 'true') { 89 $def->setStatic(true); 90 } 91 87 92 // give definition the correct class loader 88 93 if ($this->defParser->hasClassLoader($this->defParser->getCurrentNamespace()) == true) { trunk/XJConf/definitions/handler/ConcreteTagDefinitionHandler.php
r62 r77 86 86 $def->setSetterMethod($atts['setter']); 87 87 } 88 88 89 // static 90 if (isset($atts['static']) == true && strtolower($atts['static']) == 'true') { 91 $def->setStatic(true); 92 } 93 89 94 // give definition the correct class loader 90 95 if ($this->defParser->hasClassLoader($this->defParser->getCurrentNamespace()) == true) { trunk/autopackage2.php
r76 r77 50 50 - New feature to define abstract tags, which enables yo to define the concrete type in the tag instead of the definition (mikey) 51 51 - It is now possible to define an explicit setter method for character data inside a tag (schst) 52 - Added possibility to declare tags as static (schst) 52 53 - Added several unit tests (mikey) 53 54 Bugfixes: trunk/package.php
r76 r77 44 44 - New feature to define abstract tags, which enables yo to define the concrete type in the tag instead of the definition (mikey) 45 45 - It is now possible to define an explicit setter method for character data inside a tag (schst) 46 - Added possibility to declare tags as static (schst) 46 47 - Added several unit tests (mikey) 47 48 Bugfixes:
