Changeset 46
- Timestamp:
- 11/27/06 22:15:12 (2 years ago)
- Files:
-
- trunk/XJConf/DefinitionParser.php (modified) (5 diffs)
- trunk/XJConf/XJConfClassLoader.php (added)
- trunk/XJConf/XmlParser.php (modified) (1 diff)
- trunk/XJConf/definitions/TagDefinition.php (modified) (6 diffs)
- trunk/XJConf/definitions/handler/TagDefinitionHandler.php (modified) (1 diff)
- trunk/examples/ClassLoader.php (added)
- trunk/examples/ExampleClassLoader.php (added)
- trunk/examples/hidden (added)
- trunk/examples/hidden/MyNestedClass.php (added)
- trunk/examples/xml/defines-classloader.xml (added)
- trunk/examples/xml/test-classloader.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/XJConf/DefinitionParser.php
r19 r46 71 71 */ 72 72 private $nodeTypes = array(); 73 /** 74 * hashmap of class loaders where the key is the namespace the class loader 75 * should be used for 76 * 77 * @var array<String,XJConfClassLoader> 78 */ 79 private $classLoaders = array(); 73 80 74 81 /** … … 77 84 * Sets the node types depending on your PHP version using the constants 78 85 * defined by the XMLReader PHP extension. 79 */ 80 public function __construct() 86 * 87 * @param array<String,XJConfClassLoader> $classLoaders optional 88 */ 89 public function __construct($classLoaders = array()) 81 90 { 82 91 $this->defs = new NamespaceDefinitions(); 83 92 $this->currentNamespace = self::DEFAULT_NAMESPACE; 93 $this->classLoaders = $classLoaders; 84 94 85 95 if (!defined('XMLREADER_ELEMENT')) { … … 114 124 { 115 125 return $this->defs; 126 } 127 128 /** 129 * check whether a class loader exists for given namespace 130 * 131 * @param string $namespace 132 * @return bool 133 */ 134 public function hasClassLoader($namespace) 135 { 136 return (isset($this->classLoaders[$namespace])); 137 } 138 139 /** 140 * return the class loader for the given namespace 141 * 142 * @param string $namespace 143 * @return XJConfClassLoader 144 */ 145 public function getClassLoader($namespace) 146 { 147 148 if ($this->hasClassLoader($namespace) == true) { 149 return $this->classLoaders[$namespace]; 150 } 151 152 return null; 116 153 } 117 154 … … 164 201 } 165 202 } 166 167 203 $this->startElement($nameSpaceURI, $elementName, $attributes); 168 204 if (true === $empty) { … … 209 245 return; 210 246 } 211 247 212 248 // create the appropriate definition handler and use this 213 249 // to create the required definition trunk/XJConf/XmlParser.php
r18 r46 119 119 $this->tagDefs->appendNamespaceDefinitions($tagDefs); 120 120 } 121 122 public function getTagDefinitions() 123 { 124 return $this->tagDefs; 125 } 121 126 122 127 /** trunk/XJConf/definitions/TagDefinition.php
r43 r46 13 13 'definitions.Definition', 14 14 'exceptions.ValueConversionException', 15 'exceptions.XJConfException' 15 'exceptions.XJConfException', 16 'XJConfClassLoader' 16 17 ); 17 18 /** … … 84 85 */ 85 86 private $cdata = null; 87 /** 88 * the class loader to use 89 * 90 * @var XJConfClassLoader 91 */ 92 private $classLoader = null; 86 93 87 94 /** … … 143 150 public function getType() 144 151 { 152 if (null != $this->classLoader) { 153 return $this->classLoader->getType($this->type); 154 } 155 145 156 return $this->type; 146 157 } … … 160 171 $data = ''; 161 172 } 162 173 163 174 // no constructor definition has been set, 164 175 // create a new one … … 381 392 return false; 382 393 } 394 395 /** 396 * set the class loader for this tag 397 * 398 * @param XJConfClassLoader $classLoader 399 */ 400 public function setClassLoader(XJConfClassLoader $classLoader) 401 { 402 $this->classLoader = $classLoader; 403 } 383 404 384 405 /** … … 389 410 private function getValueConverter() 390 411 { 412 if (null != $this->classLoader) { 413 $this->classLoader->loadClass($this->type); 414 } 415 391 416 if (null == $this->valueConverter) { 392 417 $this->valueConverter = ValueConverterFactoryChain::getFactory($this)->createValueConverter($this); trunk/XJConf/definitions/handler/TagDefinitionHandler.php
r19 r46 86 86 $def->setSetterMethod($atts['setter']); 87 87 } 88 89 // give definition the correct class loader 90 if ($this->defParser->hasClassLoader($this->defParser->getCurrentNamespace()) == true) { 91 $def->setClassLoader($this->defParser->getClassLoader($this->defParser->getCurrentNamespace())); 92 } 88 93 89 94 return $def;
