Changeset 98

Show
Ignore:
Timestamp:
03/29/07 22:10:40 (2 years ago)
Author:
mikey
Message:

added possibility to have a default classloader which applies for every namespace if there is no specialized class loader for this namespace

Files:

Legend:

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

    r94 r98  
    3232     */ 
    3333    const TAG_NAMESPACE      = 'namespace'; 
    34        /** 
     34    /** 
    3535     * stack for currently open definitions 
    3636     * 
     
    135135    public function hasClassLoader($namespace) 
    136136    { 
    137         return (isset($this->classLoaders[$namespace])); 
     137        return (isset($this->classLoaders[$namespace]) == true || isset($this->classLoaders['__default']) == true); 
    138138    } 
    139139 
     
    146146    public function getClassLoader($namespace) 
    147147    { 
    148  
    149         if ($this->hasClassLoader($namespace) == true) { 
     148        if (isset($this->classLoaders[$namespace]) == true) { 
    150149            return $this->classLoaders[$namespace]; 
     150        } 
     151         
     152        if (isset($this->classLoaders['__default']) == true) { 
     153            return $this->classLoaders['__default']; 
    151154        } 
    152155 
     
    185188    { 
    186189        $this->initParser(); 
    187        $this->reader->open($filename); 
     190        $this->reader->open($filename); 
    188191        while ($this->reader->read()) { 
    189192            switch ($this->reader->nodeType) { 
     
    194197                    $empty = $this->reader->isEmptyElement; 
    195198                    if (TRUE == $this->reader->hasAttributes) { 
    196                                // go to first attribute 
    197                                $attribute = $this->reader->moveToFirstAttribute(); 
    198                                // save data of all attributes 
    199                                while (TRUE == $attribute) { 
    200                                        $attributes[$this->reader->localName] = $this->reader->value; 
    201                                    $attribute = $this->reader->moveToNextAttribute(); 
    202                                } 
    203                            } 
     199                        // go to first attribute 
     200                        $attribute = $this->reader->moveToFirstAttribute(); 
     201                        // save data of all attributes 
     202                        while (TRUE == $attribute) { 
     203                            $attributes[$this->reader->localName] = $this->reader->value; 
     204                            $attribute = $this->reader->moveToNextAttribute(); 
     205                        } 
     206                    } 
    204207                    $this->startElement($nameSpaceURI, $elementName, $attributes); 
    205208                    if (true === $empty) { 
     
    238241        // a new namespace 
    239242        if (self::TAG_NAMESPACE  == $sName) { 
    240                if (isset($atts['uri']) == false) { 
    241                throw new InvalidNamespaceDefinitionException('The <' . self::TAG_NAMESPACE . '> tag is missing the uri attribute.'); 
     243            if (isset($atts['uri']) == false) { 
     244                throw new InvalidNamespaceDefinitionException('The <' . self::TAG_NAMESPACE . '> tag is missing the uri attribute.'); 
    242245            } 
    243246 
    244247            // change current namespace to new namespace 
    245248            $this->currentNamespace = $atts['uri']; 
    246                return; 
     249            return; 
    247250        } 
    248251 
     
    256259 
    257260        array_push($this->defHandlerStack, $defHandler); 
    258        
     261   
    259262 
    260263    /**