Changeset 1119

Show
Ignore:
Timestamp:
12/06/07 13:52:10 (10 months ago)
Author:
mikey
Message:

always load stubMemphisTemplate when required, but load pat* only when first instance of stubMemphisTemplate is created

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisIncludeTemplatePageElement.php

    r1113 r1119  
    88 */ 
    99stubClassLoader::load('net.stubbles.lang.exceptions.stubFileNotFoundException', 
    10                       'net.stubbles.websites.memphis.stubMemphisPageElement' 
     10                      'net.stubbles.websites.memphis.stubMemphisPageElement', 
     11                      'net.stubbles.websites.memphis.stubMemphisTemplate' 
    1112); 
    1213/** 
  • trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisTemplate.php

    r814 r1119  
    88 */ 
    99stubClassLoader::load('net.stubbles.lang.exceptions.stubIllegalAccessException', 
    10                       'net.stubbles.util.stubRegistry', 
    11                       'net.stubbles.util.ext.stubPhpToolsClassLoader' 
     10                      'net.stubbles.util.stubRegistry'                       
    1211); 
    1312/** 
     
    2625     */ 
    2726    protected $template; 
    28  
    2927    /** 
    30      * static initializing 
     28     * switch whether template classes are already initialized or not 
     29     * 
     30     * @var  bool 
    3131     */ 
    32     public function __static() 
    33     { 
    34         $patClassLoader = new stubPhpToolsClassLoader(stubRegistry::getConfig('net.php-tools.path', stubConfig::getLibPath() . '/pat')); 
    35         stubClassLoader::registerForeignClassLoader($patClassLoader); 
    36         stubClassLoader::load('net.php-tools.patErrorManager'); 
    37         stubClassLoader::load('net.php-tools.patTemplate'); 
    38     } 
     32    protected static $initialized = false; 
    3933 
    4034    /** 
     
    4741    public function __construct($baseDir, array $namespaces = array(), array $options = array()) 
    4842    { 
    49         if (count($namespaces) == 0) { 
     43        if (false === self::$initialized) { 
     44            // do not use __static() because we want to load the code only when 
     45            // it is really required 
     46            stubClassLoader::load('net.stubbles.util.ext.stubPhpToolsClassLoader'); 
     47            $patClassLoader = new stubPhpToolsClassLoader(stubRegistry::getConfig('net.php-tools.path', stubConfig::getLibPath() . '/pat')); 
     48            stubClassLoader::registerForeignClassLoader($patClassLoader); 
     49            stubClassLoader::load('net.php-tools.patErrorManager'); 
     50            stubClassLoader::load('net.php-tools.patTemplate'); 
     51            self::$initialized = true; 
     52        } 
     53         
     54        if (count($namespaces) === 0) { 
    5055            $namespaces = array('patTemplate'); 
    5156        } 
    5257         
    53         if (isset($options['componentExtension']) == false) { 
     58        if (isset($options['componentExtension']) === false) { 
    5459            $options['componentExtension'] = '.tmpl'; 
    5560        }